Пример #1
0
// ---------------------------------------------------------------------------------------------------------------------
func (this *EM) initEM() {
	this.SmtpAuth = smtp.PlainAuth("",
		this.EmailConfig.Username,
		this.EmailConfig.Password,
		this.EmailConfig.EmailServer)
	this.Message = mailbuilder.NewMessage()
}
Пример #2
0
// Last call.  This sends the message.
func (this *EM) SendIt() (err error) {

	if !this.altSetup {
		err = errors.New("Error(12022): Can not send an email without a body or attachments.")
		return
	}

	this.Message.SetBody(this.Mixed)

	err = smtp.SendMail(this.EmailConfig.EmailServer+":"+strconv.Itoa(this.EmailConfig.Port),
		this.SmtpAuth,
		this.Message.From.Email,
		this.Message.Recipients(),
		this.Message.Bytes())

	if err != nil {
		e := fmt.Sprintf("Error(12021): SMTP Send Error: %v", err)
		if this.printErrors {
			fmt.Printf("%s\n", e)
		}
		err = errors.New(e)
		this.Err = err
	}

	this.Message = mailbuilder.NewMessage()

	return
}