Sending e-mail with authentication (TLS)

decrypt

Junior Contributor
Joined
Oct 6, 2003
Messages
216
this is my code:

Code:
				System.Web.Mail.MailMessage message2 = new System.Web.Mail.MailMessage();

				message2.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
				message2.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "my [email]email@gmail.com[/email]");
				message2.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "my password");
				message2.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "587");

				message2.From = "myemail@gmail.com";
				message2.To = "someone@someplace.com";
				message2.Subject = "Message Subject";
				message2.Body = "Message Body";
				message2.BodyFormat = System.Web.Mail.MailFormat.Html;

				System.Web.Mail.SmtpMail.SmtpServer = "smtp.gmail.com";
				System.Web.Mail.SmtpMail.Send(message2);

When I try to send mail I get this error:

"The server rejected the sender address. The server response was: 530 5.7.0 Must issue a STARTTLS command first"

How could I enable TLS when I send the mail?
 
Back
Top