// AddRecipients accepts one or more string that can be, itself, comma
// separated lists of email addresses, which are then added to the
// recipients for the logger.
428624
func (o *SMTPOptions) AddRecipients(addresses ...string) error {
	if len(addresses) == 0 {
		return errors.New("AddRecipients requires one or more strings that contain comma " +
			"separated email addresses")
	}

	o.mutex.Lock()
	defer o.mutex.Unlock()

	addrs, err := mail.ParseAddressList(strings.Join(addresses, ","))
	if err != nil {
		return err
	}

	o.toAddrs = append(o.toAddrs, addrs...)

	return nil
}
878529
func (h *SMTPAPIHeader) AddTos(emails []string) {
	for i := 0; i < len(emails); i++ {
		h.AddTo(emails[i])
	}
}
1235891
func (b *Batch) Add(m *utils.Message) {
	newReport := m.Reports.Pop()
	b.Message.Reports.Push(newReport)

	newPayload, _ := m.PopPayload()
	b.Writer.Write(newPayload)

	atomic.AddUint64(&b.MessageCount, 1)
}
1318563
func (c *Conn) AddSubscriptionMessage(msg interface{}) {
	resp := Response{}
	resp.Response = msg
	c.SubResponses = append(c.SubResponses, resp)
}
55994
func (s *ReceiptRule) SetRecipients(v []*string) *ReceiptRule {
	s.Recipients = v
	return s
}
98168
func (h Headers) AddHeaders(o Headers) Headers {
	r := append(h, o...)
	return r
}
974239
func (formatters FormatterArray) ApplyFormatter(msg *Message) error {
	for _, formatter := range formatters {
		if formatter.CanBeApplied(msg) {
			if err := formatter.ApplyFormatter(msg); err != nil {
				return err
			}
		}
	}
	return nil
}
863655
func (q *queue) DeliverReceipts(id string, receiptList [][]*types.Receipt) (int, error) {
	q.lock.Lock()
	defer q.lock.Unlock()

	reconstruct := func(header *types.Header, index int, result *fetchResult) error {
		if types.DeriveSha(types.Receipts(receiptList[index])) != header.ReceiptHash {
			return errInvalidReceipt
		}
		result.Receipts = receiptList[index]
		return nil
	}
	return q.deliver(id, q.receiptTaskPool, q.receiptTaskQueue, q.receiptPendPool, q.receiptDonePool, receiptReqTimer, len(receiptList), reconstruct)
}
1311380
func marshalRecipients(r []string) []byte {
	if len(r) == 0 {
		return []byte("\n")
	}

	// deduplicate
	m := make(map[string]struct{}, len(r))
	for _, k := range r {
		m[k] = struct{}{}
	}
	// sort
	keys := make([]string, 0, len(m))
	for k := range m {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	out := bytes.Buffer{}
	for _, k := range keys {
		_, _ = out.WriteString(k)
		_, _ = out.WriteString("\n")
	}

	return out.Bytes()
}
349724
func (m *MailYak) writeAttachments(mixed partCreator, splitter writeWrapper) error {
	h := make([]byte, sniffLen)

	for _, item := range m.attachments {
		hLen, err := item.content.Read(h)
		if err != nil && err != io.EOF {
			return err
		}

		if item.mimeType == "" {
			item.mimeType = http.DetectContentType(h[:hLen])
		}

		ctype := fmt.Sprintf("%s;\n\tfilename=%q", item.mimeType, item.filename)

		part, err := mixed.CreatePart(getMIMEHeader(item, ctype))
		if err != nil {
			return err
		}

		encoder := base64.NewEncoder(base64.StdEncoding, splitter.new(part))
		if _, err := encoder.Write(h[:hLen]); err != nil {
			return err
		}

		// More to write?
		if hLen == sniffLen {
			if _, err := io.Copy(encoder, item.content); err != nil {
				return err
			}
		}

		if err := encoder.Close(); err != nil {
			return err
		}
	}

	return nil
}
1073226
func HasRecipientFunc(ctx context.Context) bool {
	imf, ok := ctx.Value(ctxKeyRecipientFunc).(store.RecipientCallback)
	return ok && imf != nil
}
324984
func (s *SendBounceInput) SetBouncedRecipientInfoList(v []*BouncedRecipientInfo) *SendBounceInput {
	s.BouncedRecipientInfoList = v
	return s
}
838840
func ConfirmRecipients(ctx context.Context, crypto backend.Crypto, name string, recipients []string) ([]string, error) {
	if ctxutil.IsNoConfirm(ctx) || !ctxutil.IsInteractive(ctx) {
		return recipients, nil
	}

	ris, err := getRecipientInfo(ctx, crypto, name, recipients)
	if err != nil {
		return nil, err
	}

	if ctxutil.IsEditRecipients(ctx) {
		return confirmEditRecipients(ctx, name, ris)
	}

	return confirmAskRecipients(ctx, name, ris)
}
669681
func (c *SimpleComponentMatcher) AddComponents(sc ...StaticComponent) {
	c.comp = append(c.comp, sc...)
}
415965
func (streamer *Demultiplexer) AddEvents(ctx context.Context, events []*event.Event) error {
	if len(events) == 0 {
		return nil
	}
	streamer.handleLateOrFutureEvents(events)
	var errs []error
	for _, sendTo := range streamer.EventSinks {
		if err := sendTo.AddEvents(ctx, events); err != nil {
			errs = append(errs, err)
		}
	}
	return errors.NewMultiErr(errs)
}
1114153
func readRecipientsList(filename string) ([]recipient, error) {
	f, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	reader := csv.NewReader(f)
	record, err := reader.Read()
	if err != nil {
		return nil, err
	}
	if len(record) == 0 {
		return nil, fmt.Errorf("no entries in CSV")
	}
	if record[0] != "id" {
		return nil, fmt.Errorf("first field of CSV input must be an ID.")
	}
	var columnNames []string
	for _, v := range record[1:] {
		columnNames = append(columnNames, strings.TrimSpace(v))
	}

	results := []recipient{}
	for {
		record, err := reader.Read()
		if err == io.EOF {
			if len(results) == 0 {
				return nil, fmt.Errorf("no entries after the header in CSV")
			}
			return results, nil
		}
		if err != nil {
			return nil, err
		}
		if len(record) == 0 {
			return nil, fmt.Errorf("empty line in CSV")
		}
		if len(record) != len(columnNames)+1 {
			return nil, fmt.Errorf("Number of columns in CSV line didn't match header columns."+
				" Got %d, expected %d. Line: %v", len(record), len(columnNames)+1, record)
		}
		id, err := strconv.Atoi(record[0])
		if err != nil {
			return nil, err
		}
		recip := recipient{
			id:    id,
			Extra: make(map[string]string),
		}
		for i, v := range record[1:] {
			recip.Extra[columnNames[i]] = v
		}
		results = append(results, recip)
	}
}
553853
func (m *Message) AddRecipient(recipient string) error {
	return m.AddRecipientAndVariables(recipient, nil)
}