blah blah blah is here! blah blah » Close

up1down
link

I've been trying to get my application to send automated email by using a gmail account set up for the purpose, using SMTP. This is an account using Google Apps email, which uses the same servers as gmail for SMTP.

I have already enabled SMTP in gmail, and I'm using SSL like I should.

Also, my port 465 is not blocked for outgoing traffic.

Here is the code for my send mail method:

public static bool SendMail(MailMessage message)
{
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("admin@johnkiddapps.com", "********");
client.Host = "smtp.gmail.com";
client.Port = 465;
client.Timeout = 5000;

try
{
client.Send(message);
}
catch (SmtpException ex)
{
return false;
}
return true;
}

foamy
2499

Are you able to log in to the GMail account using those credentials?

jkidd01
30

I am able to log in using the credentials I am using.

@foamy ah you must have a google apps mail account to you the mygmailaccount@customname.com

last answered one year ago

1 answers

up1down
link

I remember something similar when setting up gmail on an MS outlook install.

change your port to 587.

client.Port = 587;

Feedback