您的位置:首页 > 产品设计 > UI/UE

The SMTP server requires a secure connection or the client was not authenticated

2009-12-03 21:41 489 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐