大佬教程收集整理的这篇文章主要介绍了golang发送邮件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
经测试成功 转自http://blog.csdn.net/zistxym/article/details/20235023
package main import ( "log" "net/smtp" "flag" "fmt" "Strings" ) var ( subject = flag.String( "s","","subject of the mail" ) body= flag.String( "b","body of themail" ) reciMail = flag.String( "m","recipient mail address" ) ) func main() { // Set up authentication information. flag.Parse() sub := fmt.Sprintf("subject: %s\r\n\r\n",*subject) content := *body mailList := Strings.Split( *reciMail,",") auth := smtp.plainAuth( "","smtpuser@example.com","password","smtp.example.com",//"smtp.gmail.com",) // Connect to the server,authenticate,set the sender and recipient,// and send the email all in one step. err := smtp.SendMail( "smtp.example.com:25",auth,"senduser@example.com",mailList,[]byte(sub+content),) if err != nil { log.Fatal(err) } } //该代码片段来自于: http://www.sharejs.com/codes/go/5641
http://www.freehao123.com/mail-smtp/
其中:
QQ邮箱POP3服务器(端口995):qq.com,SMTP服务器(端口465或587):smtp.qq.com,账户名:您的QQ邮箱账户名(如果您是VIP帐号或Foxmail帐号,账户名需要填写完整的邮件地址),密码:您的QQ邮箱密码,电子邮件地址:您的QQ邮箱的完整邮件地址。
-------------------------------------------------------------------------------------------------------------------------------------------------------
网易免费邮箱SMTP 服务器:smtp.126.com,smtp.163.com,smtp.yeah.net, SSL:否,服务器端口:25 ,发送延时 20秒,163VIP邮箱:每天限制最多能发送800封邮件。163 、 126 、 yeah 的邮箱:一封邮件最多发送给 40 个收件人,每天发送限额为 50 封。
-------------------------------------------------------------------------------------------------------------------------------------------------------
2009年7月30日新浪正式推出CN免费邮箱,新浪免费邮箱发信(smtp)服务器的地址为:smtp.sina.com,收信(pop3)服务器的地址为:pop.sina.com,设置完成后,注意一定要选择smtp服务器要求身份验证选项。
以上是大佬教程为你收集整理的golang发送邮件全部内容,希望文章能够帮你解决golang发送邮件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。