I made a simple program to send e-mails, but it fails to send them and gives me an exception.
Here's the code:
using System.Net;
using System.Net.Mail;
public class test{
public static void Main()
{
SmtpClient client = new SmtpClient();
client.Host = "smtp.gmail.com";
client.Port = 465;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("[email protected]","mypassword");
client.Send("[email protected]","[email protected]","Test","Test");
}
}
NOTE: Just added the following lines of code:
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
and changed the port to 587, then it says that authentication is required, and I alredy put my credentials, maybe its because the port 587 needs TLS not SSL (from what I learned searching about this today, I know that SSL is an "evolution" of TLS, no?)
Tunigamer, just tried the code below and that worked:
Also, I received this notification below from GMAIL, you will need to disable the sign-in security features of your account: