I want to set up an smtp server to send mail from an application. i have a newly created gmail account... i just do not know how to hard code it... i have attempted it and got the error:
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. 21sm7434001fks.39"

please help

7 Years
Discussion Span
Last Post by alanm123

That is an SMTP client, not a server. You need to use SSL on your SmtpClient . I think its called an X509 Certificate in the CLR.


ok so i enabled SSL connections and i get this error: Server does not support secure connections.

public static void SendMailQ(MailMessage Message)
      SmtpClient cli = new SmtpClient("smtp.gmail.com");
      cli.UseDefaultCredentials = false;
      cli.EnableSsl = true;
      cli.Credentials = new System.Net.NetworkCredential("accountname@gmail.com", "password_for_accountname");


Hey all,

I had the same error recently (using cdo.message). I was using smtp.gmail.com as outgoing server. It requires ssl, which I set to true, but still didn't work until I set the port to 465 (which may be specific to gmail).

Basically, among other settings, I needed these:
(My code is vbScript, not C#. Obviously, it's not a factor.)
Set myEmail = CreateObject("CDO.Message")
schemasURL = "http://schemas.microsoft.com/cdo/configuration/"
With myEmail.Configuration.Fields
.Item(schemasURL & "sendusing") = 2
.Item(schemasURL & "smtpserver") = "smtp.gmail.com"
.Item(schemasURL & "smtpusessl") = True
.Item(schemasURL & "smtpserverport") = 465
.Item(schemasURL & "sendusername") = smtpAccountName
.Item(schemasURL & "sendpassword") = smtpAccountPassword
.Item(schemasURL & "smtpauthenticate") = 1 'cdoBasic
End With

Good luck,

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.