The SMTP server requires a secure connection or the client was not authenticated
From: http://forums.asp.net/t/1199382.aspx
heelo, i have a register.aspx file. When i am going to complete the registration i get an error
Register.aspx code
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" CancelDestinationPageUrl="~/error.htm" CompleteSuccessText="Your account has been successfully created.You can now log in" ContinueDestinationPageUrl="~/Default.aspx" DisplayCancelButton="True" DuplicateUserNameErrorMessage="This username already exists.Please enter a different user name." FinishDestinationPageUrl="/Default.aspx" Font-Size="10pt" SkipLinkText="Skip" MailDefinition-BodyFileName="~/registration.txt" MailDefinition-From="mygmailname@gmail.com" MailDefinition-Priority="High" MailDefinition-Subject="Activate your WebSite Account" MailDefinition-IsBodyHtml="true" Width="310px" LoginCreatedUser="False" > <WizardSteps> <asp:CreateUserWizardStep runat="server"> </asp:CreateUserWizardStep> <asp:CompleteWizardStep runat="server"> </asp:CompleteWizardStep> </WizardSteps> </asp:CreateUserWizard>
Web.Config
<mailSettings> <smtp from="mygmailname@gmail.com"> <network host="smtp.gmail.com" userName="mygamailname@gmail.com" password="mypass" defaultCredentials="true" /> </smtp> </mailSettings>
Error I get
Server Error in '/' Application. -------------------------------------------------------------------------------- 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 j12sm16503842fkf.6 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 j12sm16503842fkf.6 Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [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 j12sm16503842fkf.6] System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) +849368 System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) +39 System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) +95 System.Net.Mail.SmtpClient.Send(MailMessage message) +2004 System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +341 System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() +571 System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) +105 System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +453 System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) +149 System.Web.UI.WebControls.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) +17 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833
Help
Thank you in Advance
====================
If you're sending email through an SSL SMTP like GMail, then you have to set the SmtpClient.EnableSsl to True. About the only way to do this is to override the email functionality of CreateUserWizard. Use the SendingMail event method to define your MailMessage and SmtpClient and then use the Cancel property to prevent the CreateUserWizard from sending its automated email.
====================
You can refer to some of my previous posts
http://forums.asp.net/p/1156294/1899489.aspx#1899489
http://forums.asp.net/p/1144253/1848821.aspx#1848821
http://forums.asp.net/p/1117050/1736785.aspx#1736785
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY