body := "this is sample text"
from := "sample@gmail.com"
to := "sample2@gmail.com"
subject := "Subject: Passporte - Invitation\n"
mime := "MIME-version: 1.0;\r\nContent-Type: text/html; charset=\"UTF-8\";\n\n"
message := []byte(subject + mime + "\n" + body)
if err := smtp.SendMail("smtp.gmail.com:587", smtp.PlainAuth("", "sample2@gmail.com", "12345678", "smtp.gmail.com"), from, []string{to}, []byte(message)); err != nil {
log.Println(err)
}
我正在使用此代码发送电子邮件。它在localhost中工作,但是当上传到服务器时,邮件服务不起作用,并且在控制台中没有显示错误。