TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sameer shaikh
NA
177
39.2k
How to solve " STARTTLS command first"?
May 15 2017 9:25 AM
Hi
I am getting exceptions durring sending email.
My code
var message = new MimeMessage();
message.From.Add(new MailboxAddress(from));
message.To.Add(new MailboxAddress(to));
message.Subject = "Simple mail'?";
message.Body = new TextPart("plain")
{
Text = body
};
using (var client = new MailKit.Net.Smtp.SmtpClient())
{
// For demo-purposes, accept all SSL certificates (in case the server supports STARTTLS)
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("smtp.gmail.com", 587, SecureSocketOptions.StartTlsWhenAvailable);
// Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2");
// Note: only needed if the SMTP server requires authentication
client.Authenticate("
[email protected]
", "password");
try
{
client.Send(message);
client.Disconnect(true);
}catch(Exception ex)
{
}
Exceptions: SMTP server does not support secure Authentication.
if comment
client.Authenticate("
[email protected]
", "password"); then getting this exception,
"
5.7.0 Must issue a STARTTLS command first. v64sm22788514pfk.86 - gsmtp"
please let me know how is coming and where am i wrong.
Thanks and Reagards
Sameer Shaikh
Reply
Answers (
2
)
Substituting default images when no image is present
Asp.Net reporting usjng rdlc report