0
我尝试在ASP.net中通过SMTP发送电子邮件,但电子邮件没有发送,也没有给出任何错误。我的代码:电子邮件不在ASP.net中使用SMTP发送
//create the mail message
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
//set the FROM address
mail.From = new MailAddress("[email protected]");
//set the RECIPIENTS
mail.To.Add("[email protected]");
//enter a SUBJECT
mail.Subject = "Set the subject of the mail here.";
//Enter the message BODY
mail.Body = "Enter text for the e-mail here.";
//set the mail server (default should be smtp.1and1.com)
SmtpClient smtp = new SmtpClient("smtp.1and1.com");
//Enter your full e-mail address and password
smtp.Credentials = new NetworkCredential("[email protected]", "xxxxxxx");
//send the message
smtp.Send(mail);
而且我在web.config中的代码是
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\Mail\" />
</smtp>
</mailSettings>
<defaultProxy enabled="true" />
</system.net>
你的smtp端口可能被阻塞或凭据可能是错误的 –