System.Net.Mail的发信问题
System.Net.Mail
SmtpClient newclient = new SmtpClient("ddd.aaa.com");
newclient.UseDefaultCredentials = false;
newclient.Credentials = new System.Net.NetworkCredential("123@ddd.aaa.com", "111");
newclient.DeliveryMethod = SmtpDeliveryMethod.Network;
newclient.Send(msgMail);
因为我现在的from邮箱地址跟host是在同一个网络中。这样可以发信成功的。
但是我如果把host改成外网的邮件服务器
SmtpClient newclient = new SmtpClient("ccc.bbb.com");
newclient.UseDefaultCredentials = false;
newclient.Credentials = new System.Net.NetworkCredential("123@111.222.com", "111");
newclient.DeliveryMethod = SmtpDeliveryMethod.Network;
newclient.Send(msgMail);
这样的话就发送不成功,说指令不认可。验证不成功
但是外网的邮件服务器的情况下using System.Web.Mail;这个就可以成功
System.Web.Mail.MailMessage a = new System.Web.Mail.MailMessage();
a.To = "321@111.222.com";
a.From = "123@111.222.com";
a.Subject = "test1";
a.Body = "nihao!test!";
a.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = "1";
a.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "123@111.222.com";
a.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "111";
SmtpMail.SmtpServer = "ccc.bbb.com";
SmtpMail.Send(a);
不知道怎么改能让用System.Net.Mail的时候,用外网的邮件服务器也能发送成功,哪位大虾能指导下。