Menu

Problem sending Mail, use STARTTLS

Help
2005-05-27
2013-04-15
  • Timo Heister

    Timo Heister - 2005-05-27

    I have a problem sending mail to a specific smtp-server, in the documentation of my account it says i have to activate "STARTTLS" to send mails.

    log.txt:
    connecting to:<xxxxxx>:25[server]: 220 Welcome to Nemesis ESMTP server on <xxxxxx>
    [client]: EHLO <xxxxxx>
    [server]: 250-<xxxxxx> pleased to meet you
    [client]: AUTH LOGIN
    [server]: 250-STARTTLS
    250-AUTH PLAIN LOGIN
    250-AUTH=PLAIN LOGIN
    250-PIPELINING
    250-8BITMIME
    250-SIZE 20971520
    250 HELP
    [client]: MAIL FROM: <xxxxxx>
    [server]: 334 VXNlcm5hbWU6

     
    • Mike Bridge

      Mike Bridge - 2005-05-27

      Hi-

      Unfortunately, DotNetOpenMail doesn't provide support for STARTTLS.  I'll look at this for a future revision, but current time constraints mean it  probably won't be the near future.

      -Mike

       
  • Anonymous

    Anonymous - 2012-03-29

    Hi,

    I have modified the Smtp.SendMail() method so that it is able to handle STARTTLS command. Those codes were copied from OpenPop project in sourceforget.net.

    // new property
    public bool useSsl { get; set; }

    public void SendMail(MailMessage msg)
    {


                    if (this.username != null && this.username.Length > 0 && this.password != null && this.password.Length > 0)
                    {
                        WriteToStream(ref nwstream, "EHLO " + Dns.GetHostName() + "\r\n");
                    }
                    else
                        WriteToStream(ref nwstream, "HELO " + Dns.GetHostName() + "\r\n");

                    CheckForError(ReadFromStream(ref nwstream), ReplyConstants.OK);

    // this is the SSL codes:

                    if (useSsl)
                    {
                        WriteToStream(ref nwstream, "STARTTLS\r\n");

                        CheckForError(ReadFromStream(ref nwstream), ReplyConstants.HELO_REPLY);

                        // If we want to use SSL, open a new SSLStream on top of the open TCP stream.
                        // We also want to close the TCP stream when the SSL stream is closed
                        System.Net.Security.SslStream sslStream = null;
                        sslStream = new System.Net.Security.SslStream(this.tcpc.GetStream(), false);
                        const int defaultTimeOut = 60000;
                        sslStream.ReadTimeout = defaultTimeOut;
                        sslStream.WriteTimeout = sendTimeout;

                        // Authenticate the server
                        sslStream.AuthenticateAsClient(this.host);

                        nwstream = sslStream;
                    }
    ….
    }

    Hope someone can merge the source code into the library.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.