请耐心等待我是 ASP.NET 的新手。这是我所做的,
网页配置
<system.net>
<mailSettings>
<smtp from="mygmail@gmail.com">
<network host="smtp.gmail.com" password="mygmailpwd"
userName="mygmail@gmail.com" enableSsl="true"/>
</smtp>
</mailSettings>
</system.net>
PASSWORDRECOVERYRES.ASPX
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="PasswordRecoveryRes.aspx.cs" Inherits="PasswordRecovery" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1> Forgot Your Password?</h1>
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server"
onsendingmail="PasswordRecovery1_SendingMail"
onsendmailerror="PasswordRecovery1_SendMailError"
onverifyinganswer="PasswordRecovery1_VerifyingAnswer"
onverifyinguser="PasswordRecovery1_VerifyingUser">
<MailDefinition From="mygmail@gmail.com" Subject="Password Recovery">
</MailDefinition>
</asp:PasswordRecovery>
</asp:Content>
PASSWORDRECOVERYRES.ASPX.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
public partial class PasswordRecovery : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
PasswordRecovery1.SuccessText = e.Message.Body;
e.Cancel = true;
}
protected void PasswordRecovery1_SendMailError(object sender, SendMailErrorEventArgs e)
{
}
protected void PasswordRecovery1_VerifyingAnswer(object sender, LoginCancelEventArgs e)
{
}
protected void PasswordRecovery1_VerifyingUser(object sender, LoginCancelEventArgs e)
{
}
}
当我运行 PASSWORDRECOVERYRES.ASPX 时,我没有收到任何错误。显示以下消息
"Please return to the site and log in using the following information. User Name: username1 Password: %#;IXWh3b:Zj$:"
但是这条消息不应该从 mygmail@gmail.com 通过电子邮件发送到 username1@gmail.com 吗?我究竟做错了什么?