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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
// 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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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
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.