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

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");
      
      cli.Send(Message);
  
      

      }

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
.Update
End With

Good luck,
Alan

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.