日期:2008-08-26  浏览次数:20444 次

这两天做了一个小PROJECT,大致是一个SERVER监控系统,如果发现某部SERVER有异常,发送EMAIL到相关手机,以便在非工作时间和节假日也能及时知道系统故障。


其中一个功能就是发送EMAIL。程序是这样的:


myMailMsg.To = "888888888@mobile.att.net";


myMailMsg.From = "support@medicalit.net";


myMailMsg.Subject = "server down";


myMailMsg.Body = "Please call StarLan to chen Database Server";


myMailMsg.BodyFormat = MailFormat.Text;


SmtpMail.SmtpServer="localhost";


SmtpMail.Send(myMailMsg);


本来是用外部的SMTP SERVER


SmtpMail.SmtpServer="smtp.XXX.com";


但后来发现由于DATA CENTER的FIREWALL原因,改用


SmtpMail.SmtpServer="localhost";


运行后系统提示错误信息:


Email Fail
Could not access ''CDO.Message'' object.
Here is the full error message output:
System.Web.HttpException: Could not access ''CDO.Message'' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x8004020F): The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for 12321323@mobile.att.net


检查SMTP SERVICE,正常,估计是权限设置问题。打开IIS ADMIN,右键点击SMTP VIRTUAL SERVER(默认SMTP虚拟服务器),选择属性,在ACCESS(访问)中点RELAY(中继),增加127.0.0.1。一路OK回去。


这时候再运行程序,邮件发送成功。