代码如下:
<%@ Page Language="vb"%>
<%@ Import Namespace="System.Web.Mail" %>
<HTML>
<HEAD>
<title>SendEmail</title>
<script runat="server">
Sub Send_Click(Sender As Object,e As EventArgs)
Dim Mail As New MailMessage
Mail.To=ToText.Text
Mail.CC=CCText.Text
Mail.BCC=BCCText.Text
Mail.Subject=SubjectText.Text
Mail.Body=BodyText.Text
Mail.From="[email protected]"
SmtpMail.SmtpServer="smtp.126.com"
SmtpMail.Send(Mail)
ToLabel.Text="Mail Sent"
End Sub
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form runat="server">
<table cellspacing="1" cellpadding="1" width="700" border="0" height="22">
<tr>
<td colspan="2">
<font color="#666699">发送电子邮件程序、、</font></td>
</tr>
</table>
<table cellspacing="1" cellpadding="1" width="700" border="0" height="123">
<tr>
<td>
<asp:Label id="ToLabel" runat="server">To:</asp:Label></td>
<td>
<asp:TextBox id="ToText" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label id="CCLabel" runat="server">CC:</asp:Label></td>
<td>
<asp:TextBox id="CCText" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label id="BCCLabel" runat="server">BCC:</asp:Label></td>
<td>
<asp:TextBox id="BCCText" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label id="SubjectLabel" runat="server">Subject:</asp:Label></td>
<td>
<asp:TextBox id="SubjectText" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label id="BodyLabel" runat="server">Body:</asp:Label></td>
<td>
<asp:TextBox id="BodyText" runat="server" TextMode="MultiLine" Rows="10" Columns="60"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Button id="Send" runat="server" Text="发送" OnClick="Send_Click"></asp:Button></td>
<td>
<Input id="Reset" type="reset" Value="重填" runat="server"></td>
</tr>
</table>
</form>
</body>
</HTML>
报错如下:
服务器拒绝了一个或多个收件人地址。服务器响应为: 553 host denies relay (eyou mta)
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Runtime.InteropServices.COMException: 服务器拒绝了一个或多个收件人地址。服务器响应为: 553 host denies relay (eyou mta)
源错误:
行 14: Mail.From="[email protected]"
行 15: SmtpMail.SmtpServer="smtp.eyou.com"
行 16: SmtpMail.Send(Mail)
行 17: ToLabel.Text="Mail Sent"
行 18: End Sub
源文件: F:\SendEmail\SendEmail\SendEmail.aspx 行: 16
请大家帮忙解决这个问题,主要是解决方法和思路。
<%@ Page Language="vb"%>
<%@ Import Namespace="System.Web.Mail" %>
<HTML>
<HEAD>
<title>SendEmail</title>
<script runat="server">
Sub Send_Click(Sender As Object,e As EventArgs)
Dim Mail As New MailMessage
Mail.To=ToText.Text
Mail.CC=CCText.Text
Mail.BCC=BCCText.Text
Mail.Subject=SubjectText.Text
Mail.Body=BodyText.Text
Mail.From="[email protected]"
SmtpMail.SmtpServer="smtp.126.com"
SmtpMail.Send(Mail)
ToLabel.Text="Mail Sent"
End Sub
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form runat="server">
<table cellspacing="1" cellpadding="1" width="700" border="0" height="22">
<tr>
<td colspan="2">
<font color="#666699">发送电子邮件程序、、</font></td>
</tr>
</table>
<table cellspacing="1" cellpadding="1" width="700" border="0" height="123">
<tr>
<td>
<asp:Label id="ToLabel" runat="server">To:</asp:Label></td>
<td>
<asp:TextBox id="ToText" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label id="CCLabel" runat="server">CC:</asp:Label></td>
<td>
<asp:TextBox id="CCText" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label id="BCCLabel" runat="server">BCC:</asp:Label></td>
<td>
<asp:TextBox id="BCCText" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label id="SubjectLabel" runat="server">Subject:</asp:Label></td>
<td>
<asp:TextBox id="SubjectText" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Label id="BodyLabel" runat="server">Body:</asp:Label></td>
<td>
<asp:TextBox id="BodyText" runat="server" TextMode="MultiLine" Rows="10" Columns="60"></asp:TextBox></td>
</tr>
<tr>
<td>
<asp:Button id="Send" runat="server" Text="发送" OnClick="Send_Click"></asp:Button></td>
<td>
<Input id="Reset" type="reset" Value="重填" runat="server"></td>
</tr>
</table>
</form>
</body>
</HTML>
报错如下:
服务器拒绝了一个或多个收件人地址。服务器响应为: 553 host denies relay (eyou mta)
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Runtime.InteropServices.COMException: 服务器拒绝了一个或多个收件人地址。服务器响应为: 553 host denies relay (eyou mta)
源错误:
行 14: Mail.From="[email protected]"
行 15: SmtpMail.SmtpServer="smtp.eyou.com"
行 16: SmtpMail.Send(Mail)
行 17: ToLabel.Text="Mail Sent"
行 18: End Sub
源文件: F:\SendEmail\SendEmail\SendEmail.aspx 行: 16
请大家帮忙解决这个问题,主要是解决方法和思路。
// {
// bool isOk= false;
// MailMessage myMail= new MailMessage();
// myMail.BodyEncoding = Encoding.GetEncoding("GB2312");
// myMail.BodyFormat= (isHtml) ? MailFormat.Html:MailFormat.Text;
// myMail.To= MailTo;
// myMail.From= MailFrom;
// myMail.Subject= MailSubject;
// myMail.Body= MailBody;
// myMail.Priority= MailPriority.High;
//
//
// string sAttach="d:/test.txt,d:/test.txt";附件名字
// if (sAttach != "")
// {
// char[] delim = new char[] {','};
// foreach (string sSubstr in sAttach.Split(delim))
// {
// MailAttachment MyAttachment = new MailAttachment(sSubstr);
// myMail.Attachments.Add(MyAttachment);
// }
// }
//
//
// if(SmtpUserName!= null && SmtpUserPassWord != null)
// {
// myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
// myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", SmtpUserName);//Smtp Server 上的用户名
// myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", SmtpUserPassWord);//Smtp Server 上的密码
//
//
// }
// SmtpMail.SmtpServer = SmtpServerAddress;//Smtp Server 地址
// try
// {
// SmtpMail.Send(myMail);
// isOk= true;
// }
// catch(Exception err)
// {
// throw new Exception(err.Message);
// }
// return isOk;
//
// }
// myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", SmtpUserName);//Smtp Server 上的用户名
// myMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", SmtpUserPassWord);//Smtp Server 上的密码
http://blog.joycode.com/ghj/archive/2004/10/22/36274.aspx
第一要配置SMTP服务,第一个网址里有
第二是关于杀毒软件的,因为有的杀毒软件会屏蔽掉25端口,第二个网址上有解释,
你可以把杀毒软件先关闭掉