//Send sends an email to Sendgrid for delivery, it assumes
//bodies[0] is HTML body and bodies[1] is text.
Send sends an email to Sendgrid for delivery, it assumes
bodies[0] is HTML body and bodies[1] is text.
// Send sends an email to Sendgrid for delivery it assumes // bodies [ 0 ] is HTML body and bodies [ 1 ] is text .
func (ps FileSender) Send(m mail.Message) error {
	if len(m.Bodies) < 2 {
		return errors.New("you must specify at least 2 bodies HTML and plain text")
	}
	htmlContent := ps.addHTMLHeader(m.Bodies[0].Content, m)
	htmlPath, err := ps.saveEmailBody(htmlContent, "html", m)
	if err != nil {
		return err
	}
	plainContent := ps.addPlainHeader(fmt.Sprintf("<html><head></head><body><pre>%v</pre></body></html>", m.Bodies[1].Content), m)
	plainPath, err := ps.saveEmailBody(plainContent, "txt", m)
	if err != nil {
		return err
	}
	if !ps.Open {
		return nil
	}
	if err := browser.OpenFile(plainPath); err != nil {
		return err
	}
	if err := browser.OpenFile(htmlPath); err != nil {
		return err
	}
	return nil
}
func ( ps FileSender ) Send ( m mail . Message ) error { if len ( m . Bodies ) < 2 { return errors . New ( " " ) } htmlContent := ps . addHTMLHeader ( m . Bodies [ 0 ] . Content , m ) htmlPath , err := ps . saveEmailBody ( htmlContent , " " , m ) if err != nil { return err } plainContent := ps . addPlainHeader ( fmt . Sprintf ( " " , m . Bodies [ 1 ] . Content ) , m ) plainPath , err := ps . saveEmailBody ( plainContent , " " , m ) if err != nil { return err } if ! ps . Open { return nil } if err := browser . OpenFile ( plainPath ) ; err != nil { return err } if err := browser . OpenFile ( htmlPath ) ; err != nil { return err } return nil }
Send sends an email to Sendgrid for delivery, it assumes
bodies[0] is HTML body and bodies[1] is text.
Send sends an email to Sendgrid for delivery it assumes bodies [ 0 ] is HTML body and bodies [ 1 ] is text .