这两天做了一个小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,选择属性,在ACCESS中点RELAY,增加127.0.0.1。一路OK回去。
这时候再运行程序,邮件发送成功。
打印 | 张贴于 2004-11-06 01:09:00 | Tag:暂无标签
留言反馈
这样写没有什么实际意义,随便写了还是能发出去,所以还是不是最佳答案。要是写错了不能发出去就好了
C:\Inetpub\mailroot\Queue
//如果没有设置 SmtpServer,则使用本地 SMTP 服务器的名称
SmtpMail.SmtpServer = "";
现在总算可以用localhost了.
I have no idea why this suggestion works, but I found it on the web. I figured I would mention it, just in case Suggestion 1 did not work. Instead of specifying
SmtpMail.SmtpServer = "127.0.0.1"
try
SmtpMail.SmtpServer.Insert( 0, "127.0.0.1 or your mail server name here")
我各种解决方案都试过了,没用。
按照这个试了一下,通过!倒。
Why?
Server 对象, ASP 0177 (0x800401F3)
无效的类别字符串
/dd/guestbook/sendmail.asp, 第 17 行
是为什么
连著名的博客堂都出现了水平滚动条,是不是因为这张图片的尺寸。但愿不是吧 :)
连著名的博客堂都出现了水平滚动条,是不是因为这张图片的尺寸。但愿不是吧 :)
我从来不写SMTP代码,,在SharpDeveloper里面直接就有代码段。。。直接用就可以了。。。。
如果出问题,那肯定是SMTP Server配置不对,,,这年头会配这个的人还真不多,,,虽然这个东西很简单。。。。
Why?
可是。。。。还是不行。
我是在ISA后面,域内有exchange server,把smtpserver设置为exchangeserver,可以发出邮件,其他怎么设置都不行。
正准备把程序拿到网络服务器上直接试验一下,看是不是内网的问题
SMTP Service挂了就挂了呗