locked
sending email using smtp server RRS feed

  • Question

  • User1368407367 posted

    HI guys,

     

    i am having trouble sending an email. can some one plz help me with the smtp details for using either windows hotmail smtp server details or local host smpt details.

     I tried this for hotmail but it didnt work

    WebMail.SmtpServer = "smtp.live.com";
    WebMail.SmtpPort = 25;
    WebMail.EnableSsl = true;
    WebMail.UserName = "myHotmail@hotmail.com?";
    WebMail.From = "Kayd?";
    WebMail.Password = "myHotmailPassword?";

     


     

    Friday, November 18, 2011 7:11 PM

Answers

  • User-1205307838 posted

    Kayd

    in my first post i posted link to help page - did you read it ???

    Here is working code from that page (replace you@hotmail.com with your hotmail email and "you_hotmail_pwd" with your password)

    @{ 
    
        try { 
            // Initialize WebMail helper 
            WebMail.SmtpServer = "smtp.live.com"; 
            WebMail.SmtpPort = 587; 
            WebMail.EnableSsl = true; 
            WebMail.UserName = "you@hotmail.com"; 
            WebMail.From = "you@hotmail.com"; 
            WebMail.Password = "your_hotmail_pwd"; 
     
            // Send email 
            WebMail.Send(to: "you@hotmail.com", 
                subject: "Test subject", 
                body: "test body" 
            ); 
        } 
        catch (Exception ex ) { 
            <text> 
                <b>The email was <em>not</em> sent.</b> 
               
            </text> 
        } 
    } 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 22, 2011 11:17 AM

All replies

  • User-1205307838 posted

    What error do you see ???

    Try different port , many ISP block port 25 try 587

    username should be your hotmail email address

    sam for the FROM full email there

     

    here is some help :

    http://www.asp.net/webmatrix/tutorials/11-adding-email-to-your-web-site

    Friday, November 18, 2011 10:15 PM
  • User-821857111 posted

    Try different port , many ISP block port 25 try 587

    Port 25 is fine for Hotmail/Live. The problem, as you pointed out is that the WebMail.From argument requires an email address, not a name.

    Saturday, November 19, 2011 2:49 AM
  • User1368407367 posted

    Try different port , many ISP block port 25 try 587

    Port 25 is fine for Hotmail/Live. The problem, as you pointed out is that the WebMail.From argument requires an email address, not a name.

    Hi Mike,

    i did enter a valid email address there.

     

    this is the error message i am getting

     

    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 65.55.162.200:25 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, Int32 timeout,
    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, Int32 timeout) at System.Net.PooledStream.Activate(Object
    owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
    at System.Net.PooledStream.Activate(Object owningObject, 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.SmtpTransport.GetConnection(ServicePoint servicePoint) at
    System.Net.Mail.SmtpClient.GetConnection() at
    System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception
    stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at
    System.Web.Helpers.WebMail.Send(String to, String subject, String body, String
    from, String cc, IEnumerable`1 filesToAttach, Boolean isBodyHtml, IEnumerable`1
    additionalHeaders) at ASP._Page_ProcessRequest_cshtml.Execute() in  

    Saturday, November 19, 2011 3:11 AM
  • User-821857111 posted

    In that case, try Port 587 instead. It could be that your ISP blocks 25.

    Saturday, November 19, 2011 3:30 AM
  • User1368407367 posted

    Mike thanks for the response, seems to be "accepting" port 587

    but now i am getting this message:

    System.Net.Mail.SmtpException: Mailbox unavailable. The server response was:
    5.7.3 Requested action aborted; user not authenticated at
    System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String
    response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[]
    command, String from) at System.Net.Mail.SmtpTransport.SendMail(MailAddress
    sender, MailAddressCollection recipients, String deliveryNotify,
    SmtpFailedRecipientException& exception) at
    System.Net.Mail.SmtpClient.Send(MailMessage message) at
    System.Web.Helpers.WebMail.Send(String to, String subject, String body, String
    from, String cc, IEnumerable`1 filesToAttach, Boolean isBodyHtml, IEnumerable`1
    additionalHeaders) at ASP._Page_ProcessRequest_cshtml.Execute() in 

    Saturday, November 19, 2011 8:45 PM
  • User1368407367 posted

    any body sucessfully sent an email using webmatrix & local host to hotmail?

    Tuesday, November 22, 2011 4:12 AM
  • User-1205307838 posted

    Kayd

    in my first post i posted link to help page - did you read it ???

    Here is working code from that page (replace you@hotmail.com with your hotmail email and "you_hotmail_pwd" with your password)

    @{ 
    
        try { 
            // Initialize WebMail helper 
            WebMail.SmtpServer = "smtp.live.com"; 
            WebMail.SmtpPort = 587; 
            WebMail.EnableSsl = true; 
            WebMail.UserName = "you@hotmail.com"; 
            WebMail.From = "you@hotmail.com"; 
            WebMail.Password = "your_hotmail_pwd"; 
     
            // Send email 
            WebMail.Send(to: "you@hotmail.com", 
                subject: "Test subject", 
                body: "test body" 
            ); 
        } 
        catch (Exception ex ) { 
            <text> 
                <b>The email was <em>not</em> sent.</b> 
               
            </text> 
        } 
    } 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 22, 2011 11:17 AM
  • User1368407367 posted

    TOMCIO,

    Thanks, thats the same code i've been trying all this time. However it still didnt work. So i changed my HOTMAIL password, made it shorter, now it works Cool

    Last Question: is there a way to encrypt the password, rather than store the password in that file which could be hacked?

    Tuesday, November 22, 2011 5:30 PM
  • User-1205307838 posted

    Kayd,

    What i would suggest is to create e-mail that you only use to send mail like no-reply@yourdomain.com or website@yourdomain.com something like that.

     

    Sure there is a way to encrypt the password, BUT if someone will hack you hosting, they will have access to all files and to  the code that encrypts/decrypts your password, so don't think it is good idea.

    Tuesday, November 22, 2011 7:44 PM