I had earlier tried to send email from my site and it worked. Then i copied this working file into another directory and renamed it.
Opened this renamed site with different host port number. Is this is responsible for it?
Smtp ssl = true, username & password are correct!
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Description: An
unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Source Error:
Line 131: var confirmationUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Confirm1?confirmationCode=" + HttpUtility.UrlEncode(token));
Line 132:
Line 133: WebMail.Send( Line 134: to: email,
Line 135: subject: "Please confirm your account",
Line: 133
Stack Trace:
[SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at]
System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) +1210211
System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) +41
System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) +97
System.Net.Mail.SmtpClient.Send(MailMessage message) +1772
System.Web.Helpers.WebMail.Send(String to, String subject, String body, String from, String cc, IEnumerable`1 filesToAttach, Boolean isBodyHtml, IEnumerable`1 additionalHeaders, String bcc, String contentEncoding, String headerEncoding, String priority, String replyTo) +698
ASP._Page_Account_UserRegister_cshtml.Execute() in c:\Users\XBlaZE\Desktop\Project-X\Test1\Account\UserRegister.cshtml:133
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +68
System.Web.WebPages.WebPage.ExecutePageHierarchy() +156
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +119
Can you post the code of your _AppStart.cshtml file.
Thanks
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
I am trying to send email to the email received from registration form which is stored in variable email as follows:
@{Layout="~/_Layout.cshtml";Page.Title="Register";// Initialize general page variablesvaremail="";varpassword="";varconfirmPassword="";// Setup validationValidation.RequireField("FirstName","You must enter FirstName");Validation.RequireField("LastName","You must enter LastName");Validation.RequireField("Institution","Institute is required");Validation.RequireField("Course","You haven't entered a Course");Validation.RequireField("AdmissionYear","Admission year required");Validation.RequireField("PassOutYear","Pass out year required");Validation.RequireField("Date","Date is required");Validation.RequireField("Month","Enter Month");Validation.RequireField("Year","Birth Year required");Validation.RequireField("CurrentLoc","Current location required");Validation.RequireField("CurrentOrg","You haven't entered Organization");Validation.RequireField("Phone","Phone no required");Validation.RequireField("Mobile","Mobile no required");Validation.RequireField("email","You must specify an email address.");Validation.RequireField("password","Password cannot be blank.");Validation.Add("confirmPassword",Validator.EqualsTo("password","Password and confirmation password do not match."));Validation.Add("password",Validator.StringLength(maxLength:Int32.MaxValue,minLength:6,errorMessage:"Password must be at least 6 characters"));//Initializing variables............................varfname=Request.Form["FirstName"];varlname=Request.Form["LastName"];varinstitu=Request.Form["Institution"];varCourse=Request.Form["Course"];varadmission=Request.Form["AdmissionYear"];varpassOut=Request.Form["PassOutYear"];varcuLoc=Request.Form["CorrentLoc"];varcuOrg=Request.Form["CorrentOrg"];varphone=Request.Form["Phone"];varmobile=Request.Form["Mobile"];vardate=Request.Form["Date"];varmonth=Request.Form["Month"];varyear=Request.Form["Year"];varbirthdate= "";//Image.....WebImagephoto=null;varnewFileName="";varimagePath="";varimageThumbPath="";// If this is a POST request, validate and process dataif(IsPost){AntiForgery.Validate();email=Request.Form["email"];password=Request.Form["password"];confirmPassword=Request.Form["confirmPassword"];fname=Request.Form["FirstName"];lname=Request.Form["LastName"];institu=Request.Form["Institution"];Course=Request.Form["Course"];admission=Request.Form["AdmissionYear"];passOut=Request.Form["PassOutYear"];cuLoc=Request.Form["CurrentLoc"];cuOrg=Request.Form["CurrentOrg"];phone=Request.Form["Phone"];mobile=Request.Form["Mobile"];date=Request.Form["Date"];month=Request.Form["Month"];year=Request.Form["Year"];birthdate=String.Concat(date,"/",month,"/",year);//Image....photo=WebImage.GetImageFromRequest();if(photo!=null){newFileName=Guid.NewGuid().ToString()+"_"+Path.GetFileName(photo.FileName);imagePath=@"Images\"+newFileName;photo.Save(@"~\"+imagePath);imageThumbPath=@"Images\Thumbs\"+newFileName;photo.Resize(width:60,height:60,preserveAspectRatio:true,preventEnlarge:true);photo.Save(@"~\"+imageThumbPath);}// Validate the user's captcha answer// if (!ReCaptcha.Validate("PRIVATE_KEY")) {// ModelState.AddError("recaptcha", "Captcha response was not correct");// }// If all information is valid, create a new accountif(Validation.IsValid()){// Insert a new user into the databasevardb=Database.Open("Alumni");// Check if user already existsvaruser=db.QuerySingle("SELECT Email FROM UserProfile WHERE LOWER(Email) = LOWER(@0)",email);if(user==null){// Insert email into the profile tabledb.Execute("INSERT INTO UserProfile (Email) VALUES (@0)",email);//Insert records in Info tablevarinsertCommand="INSERT INTO Info (FirstName,LastName, Institution, Course,AdmissionYear,PassOutYear,DateOfBirth,CurrentLocation,CurrentOrg,Phone,Mobile,ImageName)"+"VALUES(@0, @1, @2,@3,@4,@5,@6,@7,@8,@9,@10,@11)";db.Execute(insertCommand,fname,lname,institu,Course,admission,passOut,birthdate,cuLoc,cuOrg,phone,mobile,newFileName);// Create and associate a new entry in the membership database.// If successful, continue processing the requesttry{boolrequireEmailConfirmation=!WebMail.SmtpServer.IsEmpty();vartoken=WebSecurity.CreateAccount(email,password,requireEmailConfirmation);if(requireEmailConfirmation){varhostUrl=Request.Url.GetComponents(UriComponents.SchemeAndServer,UriFormat.Unescaped);varconfirmationUrl=hostUrl+VirtualPathUtility.ToAbsolute("~/Account/Confirm1?confirmationCode="+HttpUtility.UrlEncode(token));WebMail.Send(to:email,subject:"Please confirm your account",body:"Your confirmation code is: "+token+". Visit <a href=\""+confirmationUrl+"\">"+confirmationUrl+"</a> to activate your account.");}if(requireEmailConfirmation){// Thank the user for registering and let them know an email is on its wayResponse.Redirect("~/Account/Thanks");}else{// Navigate back to the homepage and exitWebSecurity.Login(email,password);Response.Redirect("~/");}}catch(System.Web.Security.MembershipCreateUserExceptione){ModelState.AddFormError(e.Message);}}else{// User already existsModelState.AddFormError("Email address is already in use.");}}}}<hgroupclass="title"><h1>@Page.Title.</h1><h2>Create a new account.</h2></hgroup><formmethod="post"enctype="multipart/form-data">@AntiForgery.GetHtml()@* If at least one validation error exists, notify the user *@@Html.ValidationSummary("Account creation was unsuccessful. Please correct the errors and try again.",excludeFieldErrors:true,htmlAttributes:null)<fieldset><legend>Registration Form</legend><olstyle="font-weight: 600;"><li> FirstName: <inputtype="text"name="FirstName"value="@fname"/>
LastName:<inputtype="text"name="LastName"value="@lname"/></br></br></li><li> Institution: <selectname="Institution"><optionvalue="Institute of Technology">SMES's Institute of technology</option><optionvalue="SMES's Institute of Pharmacy">SMES's Institute of Pharmacy</option><optionvalue="Sanghavi College of Engineering">Sanghavi College of Engineering</option></select></li></br></br><liclass="email"><labelfor="email">Email address</label><inputtype="text"id="email"name="email"value="@email"@Validation.For("email")/>@* Write any email validation errors to the page *@@Html.ValidationMessage("email")</li></br><liclass="password"><labelfor="password">Password</label><inputtype="password"id="password"name="password"@Validation.For("password")/>@* Write any password validation errors to the page *@@Html.ValidationMessage("password")</li></br><liclass="confirm-password"><labelfor="confirmPassword">Confirm password</label><inputtype="password"id="confirmPassword"name="confirmPassword"@Validation.For("confirmPassword")/>@* Write any password validation errors to the page *@@Html.ValidationMessage("confirmPassword")</li></br><li>Course: <selectname="Course"><optionvalue="Computer Engg">CO</option><optionvalue="Civil Engg">CE</option><optionvalue="Mechanical Engg">ME</option><optionvalue="Electronics & Telecommunications">E&TC</option></select></li></br></br><li>Year of Admission: <inputtype="number"name="AdmissionYear"/> PassYear: <inputtype="number"name="PassOutYear"/></li></br></br><li>Date: <inputtype="number"name="Date"/> Month:<selectname="Month"><optionvalue="January">January</option><optionvalue="February">February</option><optionvalue="March">March</option><optionvalue="April">April</option><optionvalue="May">May</option><optionvalue="June">June</option><optionvalue="July">July</option><optionvalue="August">August</option><optionvalue="September">September</option><optionvalue="October">October</option><optionvalue="November">November</option><optionvalue="December">December</option></select> Year<inputtype="number"name="Year"/></li></br></br><li>Current Location: <inputtype="text"name="CurrentLoc"value="@cuLoc"/></li></br></br><li>Current Organization:<inputtype="text"name="CurrentOrg"value="@cuOrg"/></li></br></br><li>Phone no: <inputtype="text"name="Phone"/></li></br></br><li>Mobile:<inputtype="text"name="Mobile"value="@mobile"/></li></br></br><li><labelfor="Image">Image</label><br><inputtype="file"name="Image"/></li></ol><inputtype="submit"value="Register"/></fieldset></form>
I know that. Can you please post the code which you have inside your _AppStart.cshtml file and not that of Register.cshtml file.
Thanks
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
@{WebSecurity.InitializeDatabaseConnection("Alumni","UserProfile","UserId","Email",true);WebMail.SmtpServer="smtp.gmail.com";WebMail.EnableSsl=true;WebMail.UserName="test@gmail.com.";//dummy usernameWebMail.Password="Mypassword";//dummy passwordWebMail.From="Myname@gmail.com.";//same as above.}<!DOCTYPEhtml><htmllang="en"><head><metacharset="utf-8"/><title></title></head><body></body></html>
Thanks
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [2607:f8b0:400e:c03::6d]:567
Description: An
unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [2607:f8b0:400e:c03::6d]:567
Source Error:
Line 131: var confirmationUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Confirm1?confirmationCode=" + HttpUtility.UrlEncode(token));
Line 132:
Line 133: WebMail.Send( Line 134: to: email,
Line 135: subject: "Please confirm your account",
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [2607:f8b0:400e:c03::6d]:567]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +251
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +279
[WebException: Unable to connect to the remote server]
System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +6133412
System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +314
System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +322
System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) +146
System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) +222
System.Net.Mail.SmtpClient.GetConnection() +50
System.Net.Mail.SmtpClient.Send(MailMessage message) +1496
[SmtpException: Failure sending mail.]
System.Net.Mail.SmtpClient.Send(MailMessage message) +1829
System.Web.Helpers.WebMail.Send(String to, String subject, String body, String from, String cc, IEnumerable`1 filesToAttach, Boolean isBodyHtml, IEnumerable`1 additionalHeaders, String bcc, String contentEncoding, String headerEncoding, String priority, String replyTo) +696
ASP._Page_Account_UserRegister_cshtml.Execute() in c:\Users\XBlaZE\Desktop\Project-X\Test1\Account\UserRegister.cshtml:133
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +68
System.Web.WebPages.WebPage.ExecutePageHierarchy() +156
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +119
For port 25:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Source Error:
Line 131: var confirmationUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Confirm1?confirmationCode=" + HttpUtility.UrlEncode(token));
Line 132:
Line 133: WebMail.Send( Line 134: to: email,
Line 135: subject: "Please confirm your account",
Please disable ssl
EnableSsl = false;
Try it it should work.
Thanks
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. x6sm18799188pav.29
Description: An
unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. x6sm18799188pav.29
Source Error:
Line 131: var confirmationUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Confirm1?confirmationCode=" + HttpUtility.UrlEncode(token));
Line 132:
Line 133: WebMail.Send( Line 134: to: email,
Line 135: subject: "Please confirm your account",
Red77
Member
1 Points
26 Posts
SMTP Server Error
Dec 27, 2012 02:52 PM|LINK
I had earlier tried to send email from my site and it worked. Then i copied this working file into another directory and renamed it.
Opened this renamed site with different host port number. Is this is responsible for it?
Smtp ssl = true, username & password are correct!
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Source Error:
Line 131: var confirmationUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Confirm1?confirmationCode=" + HttpUtility.UrlEncode(token)); Line 132: Line 133: WebMail.Send( Line 134: to: email, Line 135: subject: "Please confirm your account",Line: 133
Stack Trace:
wavemaster
Participant
1351 Points
1162 Posts
Re: SMTP Server Error
Dec 27, 2012 03:04 PM|LINK
who are you using to send email?
Abhishek Luv
Participant
1802 Points
481 Posts
Re: SMTP Server Error
Dec 27, 2012 03:23 PM|LINK
Can you post the code of your _AppStart.cshtml file.
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
Red77
Member
1 Points
26 Posts
Re: SMTP Server Error
Dec 27, 2012 03:38 PM|LINK
I am trying to send email to the email received from registration form which is stored in variable email as follows:
Abhishek Luv
Participant
1802 Points
481 Posts
Re: SMTP Server Error
Dec 27, 2012 03:41 PM|LINK
Yes dear
I know that. Can you please post the code which you have inside your _AppStart.cshtml file and not that of Register.cshtml file.
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
Red77
Member
1 Points
26 Posts
Re: SMTP Server Error
Dec 27, 2012 04:08 PM|LINK
As you can see i am using gmail smtp server.Abhishek Luv
Participant
1802 Points
481 Posts
Re: SMTP Server Error
Dec 27, 2012 04:13 PM|LINK
Why do you have an html code block in your _AppStart.cshtml
Please enter an SMTP Port also
WebMail.SmtpServer = "smtp.gmail.com"; WebMail.EnableSsl = true; WebMail.SmtpPort = 25 or 567; WebMail.UserName = "test@gmail.com."; //dummy username WebMail.Password = "Mypassword"; //dummy password WebMail.From = "Myname@gmail.com."; //same as above.With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
Red77
Member
1 Points
26 Posts
Re: SMTP Server Error
Dec 27, 2012 04:32 PM|LINK
When using port 567 following error occured:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [2607:f8b0:400e:c03::6d]:567
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [2607:f8b0:400e:c03::6d]:567
Source Error:
Line 131: var confirmationUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Confirm1?confirmationCode=" + HttpUtility.UrlEncode(token)); Line 132: Line 133: WebMail.Send( Line 134: to: email, Line 135: subject: "Please confirm your account",Source File: c:\Users\XBlaZE\Desktop\Project-X\Test1\Account\UserRegister.cshtml Line: 133
Stack Trace:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
Source Error:
Line 131: var confirmationUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Confirm1?confirmationCode=" + HttpUtility.UrlEncode(token)); Line 132: Line 133: WebMail.Send( Line 134: to: email, Line 135: subject: "Please confirm your account",Source File: c:\Users\XBlaZE\Desktop\Project-X\Test1\Account\UserRegister.cshtml Line: 133
Stack Trace:
Abhishek Luv
Participant
1802 Points
481 Posts
Re: SMTP Server Error
Dec 27, 2012 04:40 PM|LINK
Please disable ssl
EnableSsl = false;
Try it it should work.
With Regards
Abhishek Rajiv Luv
"Helpful then please Mark as Answer"
http://www.codeabstract.com/
http://pluralsight.com/training/users/abhishekluv
Red77
Member
1 Points
26 Posts
Re: SMTP Server Error
Dec 27, 2012 04:52 PM|LINK
Getting error:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. x6sm18799188pav.29
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. x6sm18799188pav.29
Source Error:
Line 131: var confirmationUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/Account/Confirm1?confirmationCode=" + HttpUtility.UrlEncode(token)); Line 132: Line 133: WebMail.Send( Line 134: to: email, Line 135: subject: "Please confirm your account",Source File: c:\Users\XBlaZE\Desktop\Project-X\Test1\Account\UserRegister.cshtml Line: 133
Stack Trace: