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
Khushboo Kumari
NA
112
14.5k
sending mail in mvc
Jan 24 2018 4:59 AM
please help me to solve
error->Additional information: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
my code is like below
[HttpPost]
public
ViewResult Index(mail_sending.Models.MailModel _objModelMail)
{
if
(ModelState.IsValid)
{
MailMessage mail =
new
MailMessage();
mail.To.Add(_objModelMail.To);
mail.From =
new
MailAddress(_objModelMail.From);
mail.Subject = _objModelMail.Subject;
string
Body = _objModelMail.Body;
mail.Body = Body;
mail.IsBodyHtml =
true
;
SmtpClient smtp =
new
SmtpClient();
smtp.Host =
"smtp.gmail.com"
;
smtp.Port = 587;
smtp.UseDefaultCredentials =
false
;
smtp.Credentials =
new
System.Net.NetworkCredential(
"
[email protected]
"
,
"shushiladevi"
);
// Enter seders User name and password
smtp.EnableSsl =
true
;
smtp.Send(mail);
return
View(
"Index"
, _objModelMail);
}
else
{
return
View();
}
}
Reply
Answers (
4
)
How to pass the random number into mail in MVC 5
I need a sample web pages for multiple page linked with code