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
Guest User
Tech Writer
2.1k
473.9k
The SMTP server requires a secure connection or the client?
Feb 17 2020 11:38 PM
Hi Mates
I have this issue and dont know how to resolve it on my Register ActionResult, kindly please assist me.
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public
async Task<ActionResult> Register(RegisterViewModel model)
{
if
(ModelState.IsValid)
{
var user =
new
ApplicationUser() { UserName = model.UserName };
user.Email = model.Email;
user.ConfirmedEmail =
false
;
var result = await UserManager.CreateAsync(user, model.Password);
if
(result.Succeeded)
{
MailMessage msg =
new
MailMessage();
msg.From =
new
MailAddress(
"
[email protected]
"
);
msg.To.Add(
"
[email protected]
"
);
msg.Subject =
"test"
;
msg.Body =
"Test Content"
;
using
(SmtpClient client =
new
SmtpClient())
{
client.EnableSsl =
true
;
client.UseDefaultCredentials =
true
;
client.Credentials =
new
NetworkCredential(
"
[email protected]
"
,
"Mohali@5050"
);
client.Host =
"smtp.gmail.com"
;
client.Port = 587;
// client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(msg);
// This gets thrown as an error, yes google settings are set all of them.
}
return
RedirectToAction(
"Confirm"
,
"Account"
,
new
{ Email = user.Email });
}
else
{
AddErrors(result);
}
}
// If we got this far, something failed, redisplay form 478216
return
View(model);
}
Reply
Answers (
5
)
How Display Google Analytics in asp.net mvc core 3.1
how to convert data type in reports using codding