我可以';不要用umbraco发邮件

本文关键字:umbraco 我可以 | 更新日期: 2023-09-27 18:00:27

正如标题所说,我似乎无法通过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配置。。(尽管我刚开始用它,但又把它取了下来)有人能告诉我怎么了吗?

我可以';不要用umbraco发邮件

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

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