user971374
user971374

Reputation: 153

Trying to send email using gmail from ASP.NET

I am trying to send email from a ASP.MVC application using gmail.

I have set account to "Any Address" and clicked "Requires SMTP Authentication"

if I use port 25 I get error "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required."

if I use port 465 I get a timeout error "The operation has timed out."

           Using m As Net.Mail.MailMessage = New Net.Mail.MailMessage("[email protected]", "[email protected]")
            m.Subject = "test"
            m.Body = "I am testing"
            Using c As SmtpClient = New SmtpClient
                c.Send(m)
            End Using
        End Using

My webconfig

 <mailSettings>"
  <smtp from="[email protected]" >
    <network host="smtp.gmail.com"  enableSsl="true"  password="mypassword" port="465" userName="[email protected]" />
  </smtp>
</mailSettings>

Any ideas Thanks

Upvotes: 0

Views: 128

Answers (1)

SBirthare
SBirthare

Reputation: 5137

Try using port 587 as shown below:

  <smtp from="[email protected]">
    <network host="smtp.gmail.com" port="587" enableSsl="true" userName="[email protected]" password="yourpassword.123" />
  </smtp>

Upvotes: 1

Related Questions