We have set up a web site for a client who uses Google Apps for their emails.
In the web site’s contact us section, we have a form to enable a visitor send them a message. In short, the below code is used but it always times out during the ‘send’ phaze.
Dim mysmtp = New System.Net.Mail.SmtpClient
mysmtp.Host = "smtp.gmail.com"
mysmtp.Port = 465
mysmtp.EnableSsl = True
mysmtp.Timeout = 15000 ' it times out a lot later after removing this..
Dim msg As System.Net.Mail.MailMessage
msg = New System.Net.Mail.MailMessage(from:="info@xxx.org", subject:="text", body:="still testing ...", [to]:="xx@gmail.com")
Dim smtpAuthentication As New System.Net.NetworkCredential()
smtpAuthentication.Password = "mypwd"
smtpAuthentication.UserName = "info@xxx.org"
mysmtp.Credentials = smtpAuthentication
mysmtp.Send(msg)
I have tried it with firewall turned off, and anti-virus software disabled. I am using windows 7.
None of the solutions in other questions/forms worked. The problem might not be the code but I am lost.
Any help would be appreciated!
Try with port 587. Here is how the SMTP should be configured.
And if it still doesn’t work, fire up Command Prompt and do this.
Google help center link: http://support.google.com/mail/bin/answer.py?hl=en&answer=78775