3

我正在使用 asp 中的“createuserwizard”创建一个表单。这是我的代码。

<asp:CreateUserWizard ID="userwizard" ContinueDestinationPageUrl="~/secretfiles/secret.aspx" runat="server" >
    <MailDefinition BodyFileName="register.txt" Subject="Registration Confirmation" From="amrit.enest@gmail.com" />
    </asp:CreateUserWizard>

这是我的 web.config 文件设置。

 <mailSettings>
      <smtp deliveryMethod="Network" from="amrit.enest@gmail.com">
        <network host="smtp.gmail.com" port="25" userName="amrit.enest@gmail.com" password="sending emails's password" />
      </smtp>
    </mailSettings>

然后设置了一个 Smtp .in ISS 设置我选择了以下选项。

->Use localhost(SMTP)
->port=25
->authentication not required 

现在当一个新用户点击提交按钮时,它会给出以下错误消息并且邮件没有被发送。

SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应是: 5.7.0 必须首先发出 STARTTLS 命令。ud8sm21095949igb.4

请帮助各位。

4

3 回答 3

4

使用enableSsl="true",像这样:

 <mailSettings>
  <smtp deliveryMethod="Network" from="amrit.enest@gmail.com">
    <network enableSsl="true" host="smtp.gmail.com" port="25" userName="amrit.enest@gmail.com" password="sending emails's password" />
  </smtp>
</mailSettings>
于 2012-08-03T12:14:00.713 回答
0

服务器需要 SSL,因此您需要将其添加到您的配置中:

<mailSettings>
  <smtp deliveryMethod="Network" from="amrit.enest@gmail.com">
    <network host="smtp.gmail.com" port="25" userName="amrit.enest@gmail.com" 
        password="sending emails's password" enableSsl="true" />
  </smtp>
</mailSettings>

有关详细信息,请参见此处

于 2012-08-03T12:14:11.277 回答
0
protected void Button1_Click(object sender, EventArgs e)
{

    MailMessage mail = new MailMessage();
    MailAddress from = new MailAddress("your mail address@mail.com");
    SmtpClient clientobj = new SmtpClient("smtp.gmail.com");
    mail.From = from;
    mail.To.Add(new MailAddress(" to mail address@gmail.com"));
    mail.Subject = "example gridview";
    mail.Body+="Please check below data <br/><br/>";
    mail.Body += getgridviewdata(gv1);
    mail.IsBodyHtml = true;
    clientobj.Credentials = new System.Net.NetworkCredential("your mailaddress@gmail.com", "your email password");
    clientobj.Port =587;
    clientobj.EnableSsl = true;
  clientobj.Send(mail);


}

上面的 gv1 是我的 gridview id

public string getgridviewdata(GridView gv)
{
    StringBuilder strBuilder = new StringBuilder();
    StringWriter strWriter = new StringWriter(strBuilder);
    HtmlTextWriter htw = new HtmlTextWriter(strWriter);
    gv.RenderControl(htw);
    return strBuilder.ToString();
}
public override void VerifyRenderingInServerForm(Control control)
{
    /* Verifies that the control is rendered */
}

您也在源代码中编写以下内容

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="example.aspx.cs" Inherits="example" EnableEventValidation="false" %>
于 2013-03-19T13:13:17.290 回答