locked
Problems sending email via gmail smtp from webmatrix RRS feed

  • Question

  • User1546138644 posted

    Hi,

    I am currently embarking on writing my very first site "proper" site after immersing myself in tutorials and books for a month or so- So still very much a noob...

    I am trying to send an email from one of my pages having followed a tutorial on security and membership. I am initializing the WebMail helper in AppStart like this: 

    // Initialise the SMTP emailer  

    WebMail.SmtpServer="smtp.gmail.com";  

    WebMail.SmtpPort=465;

    WebMail.EnableSsl=true;  

    WebMail.UserName="<a valid gmail account>";

    WebMail.From="<the same valid gmail account";  

    WebMail.Password="<the correct password";

     

    And I am then trying to call the WebMail to send the email like this having previously initialised (and checked the values of) the variables:

                    WebMail.Send(to: email,
                                    subject: thesubject,
                                    body: thebody
                                    );
    

    All that happens is that the call times out. I have checked that the sending account is live and valid by sending a test email from it to the sample destination email address and that works fine. There is so little here to tweak I am at a bit of a loss for what to look at next... Any ideas?

     

     

     

     

     

     
    Saturday, June 29, 2013 3:15 PM

Answers

  • User-821857111 posted

    Change the port to 587.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 29, 2013 6:33 PM

All replies

  • User-1496281956 posted

    Remove the port, this can cause issues at times.

    Saturday, June 29, 2013 6:20 PM
  • User-821857111 posted

    Change the port to 587.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 29, 2013 6:33 PM
  • User1546138644 posted

    Thanks Mike. Changed to 587 and it worked a treat Cool

    Sunday, June 30, 2013 1:05 PM