Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
sending mail in mvc
Khushboo Kumari
Jan 24 2018 4:59 AM
185
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
Upload Source Code
Select only zip and rar file.
Post
Reset
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