我有一个网络表单,有人可以在其中设置帐户 - 我想向他们发送电子邮件确认。
我正在使用的代码:
// Create e-mail message
MailMessage mm = new MailMessage();
mm.From = new MailAddress("OurOrganisationEmail@ourdomain.com", "Our Organisation");
mm.To.Add(new MailAddress("webuser@domain.com", "Web User"));
mm.Subject = "Confirmation";
mm.Body = "You are now registered test";
mm.IsBodyHtml = true;
// Send e-mail
sc = new SmtpClient();
NetworkCredential basicAuthenticationInfo = new NetworkCredential(“OurOrganisationEmail@ourdomain.com”, “ourorganisationemailPassword”);
sc.Credentials = basicAuthenticationInfo;
sc.UseDefaultCredentials = false;
sc.Send(mm);
网络配置:
<system.net>
<mailSettings>
<smtp>
<network host="mail.OurOrganisationEmail@ourdomain.com" port="9999" userName="OurOrganisationEmail@ourdomain.com" password="OurOrganisationEmailPassword"/>
</smtp>
</mailSettings>
</system.net>
但是得到:
System.Net.Mail.SmtpFailedRecipientException was caught
HResult=-2146233088
Message=Mailbox unavailable. The server response was: Authentication is required for relay
Source=System
FailedRecipient=<webuser@domain.com>
看起来它想要我要发送到的网址的用户登录详细信息。我该如何修改它并像所有其他商业公司一样发送这样的确认电子邮件?