我无法在umbraco发送邮件

时间:2014-04-28 12:03:17

标签: c# web-config mailmessage

正如标题所说,我似乎无法通过umbraco表单发送邮件。

我创建了一个用户控件,其中包含以下代码:

MailMessage mail = new MailMessage();

mail.From = new MailAddress(txtEmail.Text);
mail.To.Add("xx@xx.com");
mail.Subject = "Ny Notat bestilling"
mail.IsBodyHtml = true;

msg.Subject = ddlSubject.Text;
//"<b>Bestilling: </b>" + ddlSubject.Text + "<br/>" +
mail.Body =
    "<b>Navn: </b>" + txtName.Text + "<br/>" +
    "<b>Adresse: </b>" + txtAdress.Text + "<br/>" +
    "<b>Postnummer/By: </b>" + txtZip.Text + "<br/>" +
    "<b>E-mail: </b>" + txtEmail.Text + "<br/>" +
    "<b>Telefon: </b>" + txtPhone.Text + "<br/>" +
    "<b>Set tilbudet i: </b>" + txtMessage.Text + "<br/>" +
    "<b>Evt. Besked: </b>" + txtMessage.Text + "<br/>";

SmtpClient smtp = new SmtpClient();

smtp.Send(mail);

这是我的web.config设置:

 <system.net> 
   <mailSettings> 
    <smtp deliveryMethod="Network" from="xx@xx.com">
      <network host="127.0.0.1" />
    </smtp>
   </mailSettings> 
 </system.net> 

这是我的异常追踪:

    System.Net.Mail.SmtpException: Failure sending mail. ---> 
System.Net.WebException: Unable to connect to the remote server ---> 
System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable network [2a00:1450:4010:c03::6c]:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) at
 System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at 
System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at 
System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at 
Notat.dk.UserControls.OrderForm.btnSubmit_Click(Object sender, EventArgs e) in c:\Users\DEO1\Desktop\Notat.dk Nyeste - Backup\UserControls\OrderForm.ascx.cs:line 55

我不明白为什么它说我的端口587有问题?看来我没有使用gmail smtp配置..(尽管我开始使用它,但是再次将其删除)有谁能告诉我出了什么问题?

1 个答案:

答案 0 :(得分:2)

您需要配置hotmail服务器而不是localhost 127.0.0.1

<network host="smtp.live.com" />