用system.web.mail发信,会在本地的C:\Inetpub\mailroot\Queue生成个mail文件,但是用opensmtp组件发送,出错:Expecting:250. recieved:550 5.7.1 Unable to relay for [email protected]
用opensmtp的源码:
try
{
MailMessage msg;
SmtpConfig.VerifyAddresses = true; Smtp smtp = new Smtp();
smtp.Host = this.txtSmtpServer.Text;
smtp.Port = 25;
if(!this.txtUserName.Text.Equals(""))
{
smtp.Username = this.txtUserName.Text;
smtp.Password = this.txtPassword.Text;
}
string strSplit = ",";
char[] chSplit = strSplit.ToCharArray();
string[] strTo = this.txtReceipt.Text.Split(chSplit);
for(int i = 0;i<strTo.Length;i++)
{
msg = new MailMessage(this.txtSender.Text,strTo[i]);
msg.Subject = this.txtSubject.Text;
msg.Body = this.txtContent.Text;
msg.Charset = "utf-8";
smtp.SendMail(msg);
}
}
catch(MalformedAddressException mfa)
{
MessageBox.Show("Address error occured: " + mfa.Message);
}
catch(SmtpException se)
{
MessageBox.Show("Smtp error occured: " + se.Message);
}
catch(Exception ex)
{
MessageBox.Show("Error occured: " + ex.Message + "r\n" + ex);
}