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
469.6k
Failed to connect to third party, using smtp client?
Feb 5 2020 7:12 AM
Hi Team
I have this issue, each time i am registering the new user, its connection failure to third party. I am using smtp client mail and this domain is gmail. The question why am i getting this often and its not even send a confirming email to the user. It does writes this query to the database colum. What could an issue?
[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)
{
System.Net.Mail.MailMessage m =
new
System.Net.Mail.MailMessage(
new
System.Net.Mail.MailAddress(
"
[email protected]
"
,
"Web Registration"
),
new
System.Net.Mail.MailAddress(user.Email));
m.Subject =
"Email confirmation"
;
m.Body = string.Format(
"Dear {0}<BR/>Thank you for your registration, please click on the below link to complete your registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>"
, user.UserName, Url.Action(
"ConfirmEmail"
,
"Account"
,
new
{ Token = user.Id, Email = user.Email }, Request.Url.Scheme));
m.IsBodyHtml =
true
;
System.Net.Mail.SmtpClient smtp =
new
System.Net.Mail.SmtpClient(
"smtp.gmail.com"
);
smtp.Credentials =
new
System.Net.NetworkCredential(
"
[email protected]
"
,
"password"
);
smtp.EnableSsl =
true
;
smtp.Send(m);
return
RedirectToAction(
"Confirm"
,
"Account"
,
new
{ Email = user.Email });
}
else
{
AddErrors(result);
}
}
// If we got this far, something failed, redisplay form
return
View(model);
}
Reply
Answers (
5
)
File name maybe incorrect on database path?
after login dont show login page click back button browser