private void sendMailMethod(string oFBody)
{
try
{
string oFFromMail = "912549963@qq.com";//123456@qq.com
string oFFromMailPwd ="xxxxxxxx";//这里是我刚刚在邮箱设置的独立密码密码
string oFDisName = "邮件发送服务";
string toMail = "18437963713@163.com";//接受的邮件地址 123321@qq.com
string host = "smtp.qq.com";//QQ是smtp.qq.com;其他网上百度
//以下设置服务器
MailMessage mailmsg = new MailMessage();
mailmsg.From = new MailAddress(oFFromMail, oFDisName);
mailmsg.To.Add(toMail);//"bad.huan@163.com"
mailmsg.Subject = "商品上架功能异常邮件";
mailmsg.Body = "您好啊,这是测试邮件!<br />" + oFBody;
mailmsg.BodyEncoding = System.Text.Encoding.UTF8;
mailmsg.IsBodyHtml = true;
SmtpClient sendmsg = new SmtpClient(host);
sendmsg.Host = host;
sendmsg.Credentials = new NetworkCredential(oFFromMail, oFFromMailPwd);
sendmsg.EnableSsl = true;
sendmsg.Send(mailmsg);
mailmsg.Dispose();
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
报的错误是:无法从传输连接中读取数据: net_io_connectionclosed。
或者是:
mail from address must be same as authorization user
可是我设置过Stmp和pop3的服务拉呀!哪位讲一下,拜托!!!
启用了 EnableSsl ,就需要使用 465 端口
sendmsg.Port = 465;