Question

As the title says I can't seem to send mail through an umbraco form.

I have created a user control with the following code in it:

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);

This is my web.config settings:

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

This is my exception trace:

    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

What I don't understand is why it says I have a problem with port 587? Seeing as I I'm not using gmail smtp configurations.. (All though I started out using it, but removed it again) Can anyone tell me what is wrong?

Was it helpful?

Solution

You need to configure hotmail server not localhost 127.0.0.1

<network host="smtp.live.com" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top