我创建了一个注册页面,在注册后通知用户。下面的代码适用于同一域名下的用户,但无法使用外部域电子邮件帐户。它不会返回任何错误,并且接收者也不会收到电子邮件。
...some codes here...
string bodymsg="test email";
MailMessage mMailMsg = new MailMessage();
mMailMsg.From = new MailAddress("applications@mydomain.com");
mMailMsg.To.Add(new MailAddress(mailto));
mMailMsg.Subject = "test email";
mMailMsg.Body = bodymsg;
mMailMsg.IsBodyHtml = true;
mMailMsg.Priority = MailPriority.Normal;
SmtpClient msmtpclient = new SmtpClient();
msmtpclient.Send(mMailMsg);
网页配置
<mailSettings>
<smtp>
<network host="mail.mydomain.com" password="pwd" userName="applications@mydomain.com" defaultCredentials="false" port="25"/>
</smtp>
</mailSettings>
提前致谢。