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
Atulya Raj
NA
23
3.5k
Error in Sending Email through Gmail
Jun 19 2020 3:36 PM
I have been trying to send Email in Asp.Net Core 3.1.But I always keep on getting this error System.Net.Mail.SmtpException: Server does not support secure connections.
My Source Code-
var fromAddress =
new
MailAddress(
"
[email protected]
"
,
"Atulya Raj"
);
var toAddress =
new
MailAddress(
"
[email protected]
"
,
"Name"
);
const
string
fromPassword =
"password"
;
const
string
subject =
"Test"
;
string
body =
"Hello"
var smtp =
new
SmtpClient
{
Host =
"smtp.gmail.com"
,
Port = 587,
EnableSsl =
true
,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials =
false
,
Credentials =
new
NetworkCredential(fromAddress.Address, fromPassword)
};
using
(var message =
new
MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}
Any help would be nice.Thanks.
Reply
Answers (
1
)
Get all the ActionResult as JsonResult only in mvc
how to resolve Timeout Expired Error