// Adds additional email addresses to an account.
174588
func (r *EmailResource) Create(address string) (error) {
	emails := []string{ address }
	if err := r.client.do("POST", "/user/emails", &emails, nil); err != nil {
		return err
	}

	return nil
}
516990
func NewEmailServer(host string, port int, auth smtp.Auth, sendMailFunc SendMailFunc) *EmailServer {
	return &EmailServer{
		host:         host,
		port:         port,
		auth:         auth,
		sendMailFunc: sendMailFunc,
	}
}
861925
func (api UsersAPI) UpdateEmailAddress(w http.ResponseWriter, r *http.Request) {
	username := mux.Vars(r)["username"]
	oldlabel := mux.Vars(r)["label"]
	lang := r.FormValue("lang")
	if lang == "" {
		lang = organization.DefaultLanguage
	}

	var body user.EmailAddress
	if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}
	// Email address to all lowercase
	body.EmailAddress = strings.ToLower(body.EmailAddress)
	if !body.Validate() {
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	userMgr := user.NewManager(r)
	u, err := userMgr.GetByName(username)
	if err != nil {
		log.Error("failed to get user by username: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	oldEmail, err := u.GetEmailAddressByLabel(oldlabel)
	if err != nil {
		log.Debug("Changing email address with non existing label")
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	valMgr := validationdb.NewManager(r)
	oldEmailValidated, err := valMgr.IsEmailAddressValidated(username, oldEmail.EmailAddress)
	if err != nil {
		log.Error("Failed to check if email address is verified for user: ", err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	if oldEmail.EmailAddress != body.EmailAddress && oldEmailValidated {
		log.Debug("Trying to change validated email address")
		http.Error(w, http.StatusText(http.StatusPreconditionFailed), http.StatusPreconditionFailed)
		return
	}

	if oldlabel != body.Label {
		if _, err = u.GetEmailAddressByLabel(body.Label); err == nil {
			http.Error(w, http.StatusText(http.StatusConflict), http.StatusConflict)
			return
		}
	}

	if err = userMgr.SaveEmail(username, body); err != nil {
		log.Error(err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}

	if oldlabel != body.Label {
		if err = userMgr.RemoveEmail(username, oldlabel); err != nil {
			log.Error(err)
			http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
			return
		}
	}
	validated, err := valMgr.IsEmailAddressValidated(username, body.EmailAddress)
	if err != nil {
		log.Error(err)
		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		return
	}
	if !validated {
		_, err = api.EmailAddressValidationService.RequestValidation(r, username, body.EmailAddress, fmt.Sprintf("https://%s/emailvalidation", r.Host), lang)
	}

	w.Header().Set("Content-Type", "application/json")

	w.WriteHeader(http.StatusCreated)
	json.NewEncoder(w).Encode(body)
}
1159863
func (a *Addresses) Append(address *Address) {
	a.addresses = append(a.addresses, address.address)
}
641960
func ListEmails(c *context.APIContext) {
	emails, err := models.GetEmailAddresses(c.User.ID)
	if err != nil {
		c.Error(500, "GetEmailAddresses", err)
		return
	}
	apiEmails := make([]*api.Email, len(emails))
	for i := range emails {
		apiEmails[i] = convert.ToEmail(emails[i])
	}
	c.JSON(200, &apiEmails)
}
1001638
func (g *Generator) EMail() string {
	if g.FlipCoin(50) {
		first, _, last := g.MaleName()
		return BuildEMail(first, last, g.Domain())
	}
	first, _, last := g.FemaleName()
	return BuildEMail(first, last, g.Domain())
}
1107245
func (l *LinkNode) AddAddress(addr net.Addr) error {
	for _, a := range l.Addresses {
		if a.String() == addr.String() {
			return nil
		}
	}

	l.Addresses = append(l.Addresses, addr)

	return l.Sync()
}
660428
func GetUserEmailsByNames(names []string) []string {
	mails := make([]string, 0, len(names))
	for _, name := range names {
		u, err := GetUserByName(name)
		if err != nil {
			continue
		}
		if u.IsMailable() {
			mails = append(mails, u.Email)
		}
	}
	return mails
}
984964
func Email() string {
	return strings.ToLower(FirstName(RandomGender)+LastName()) + StringNumberExt(1, "", 3) + "@" + randomFrom(jsonData.Domains)
}
389262
func (a *AddrManager) AddAddresses(addrs []*wire.NetAddress, srcAddr *wire.NetAddress) {
	a.mtx.Lock()
	defer a.mtx.Unlock()

	for _, na := range addrs {
		a.updateAddress(na, srcAddr)
	}
}
1260056
func (s *Stack) AddAddressWithOptions(id tcpip.NICID, protocol tcpip.NetworkProtocolNumber, addr tcpip.Address, peb PrimaryEndpointBehavior) *tcpip.Error {
	s.mu.RLock()
	defer s.mu.RUnlock()

	nic := s.nics[id]
	if nic == nil {
		return tcpip.ErrUnknownNICID
	}

	return nic.AddAddressWithOptions(protocol, addr, peb)
}
878529
func (h *SMTPAPIHeader) AddTos(emails []string) {
	for i := 0; i < len(emails); i++ {
		h.AddTo(emails[i])
	}
}
1214496
func (s *PublicAccountAPI) Accounts() []common.Address {
	addresses := make([]common.Address, 0) // return [] instead of nil if empty
	for _, wallet := range s.am.Wallets() {
		for _, account := range wallet.Accounts() {
			addresses = append(addresses, account.Address)
		}
	}
	return addresses
}
232230
func (r Account) SetAbuseEmails(emails []string) (resp bool, err error) {
	params := []interface{}{
		emails,
	}
	err = r.Session.DoRequest("SoftLayer_Account", "setAbuseEmails", params, &r.Options, &resp)
	return
}
662131
func (api UsersAPI) RegisterNewEmailAddress(w http.ResponseWriter, r *http.Request) {
	username := mux.Vars(r)["username"]
	body := user.EmailAddress{}
	lang := r.FormValue("lang")
	if lang == "" {
		lang = organization.DefaultLanguage
	}

	if err := json.NewDecoder(r.Body).Decode(&body); err != nil || !body.Validate() {
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	// Convert email address to lowercase
	body.EmailAddress = strings.ToLower(body.EmailAddress)

	if !body.Validate() {
		http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
		return
	}

	userMgr := user.NewManager(r)
	u, err := userMgr.GetByName(username)
	if handleServerError(w, "getting user by name", err) {
		return
	}

	if _, err := u.GetEmailAddressByLabel(body.Label); err == nil {
		writeErrorResponse(w, http.StatusConflict, "duplicate_label")
		return
	}

	err = userMgr.SaveEmail(username, body)
	if handleServerError(w, "saving email", err) {
		return
	}

	valMgr := validationdb.NewManager(r)
	validated, err := valMgr.IsEmailAddressValidated(username, body.EmailAddress)
	if handleServerError(w, "checking if email address is validated", err) {
		return
	}
	if !validated {
		_, err = api.EmailAddressValidationService.RequestValidation(r, username, body.EmailAddress, fmt.Sprintf("https://%s/emailvalidation", r.Host), lang)
	}
	w.Header().Set("Content-Type", "application/json")

	w.WriteHeader(http.StatusCreated)
	json.NewEncoder(w).Encode(body)
}
680270
func (s *EmailConfigurationType) SetEmailSendingAccount(v string) *EmailConfigurationType {
	s.EmailSendingAccount = &v
	return s
}
1088363
func NewEmailChange(g *libkb.GlobalContext, a *keybase1.EmailChangeArg) *EmailChange {
	return &EmailChange{
		arg:          a,
		Contextified: libkb.NewContextified(g),
	}
}