【发布时间】:2011-09-30 00:05:15
【问题描述】:
下面的代码让我一个接一个地出错。
MailMessage Enveloppe = new MailMessage();
//emails is an array of strings
foreach ( string email in emails )
Enveloppe.To.Add(email);
//Setup message parameters
Enveloppe.Subject = "Documentation";
Enveloppe.Body = "Infinitelycoolbodyhere"
Enveloppe.From = new MailAddress("mrzombie@stuff", "Myname");
//files is an array of strings
foreach ( string filename in files ) {
//Add attachments
Enveloppe.Attachments.Add(new Attachment(new System.Net.WebClient().OpenRead(filename),filename.Substring(filename.LastIndexOf('/'))));
}
//Create the smtp client, and let it do its job
SmtpClient Mailman = new SmtpClient("mysmtphost");
Mailman.EnableSsl = true;
Mailman.Port = 465;
Mailman.DeliveryMethod = SmtpDeliveryMethod.Network;
Mailman.Credentials = new System.Net.NetworkCredential("usernamehere", "passwordhere");
Mailman.Send(Enveloppe);
它恰好告诉我我的操作超时,或者“连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机没有响应” .
我被难住了,我看不出我做错了哪一部分
更新:我似乎无法从 Telnet 连接到服务器,充其量只能连接到我的笔记本电脑(在 ubuntu 下),但我从未收到“200”响应。在 windows 工作站下,我得到一个永久空白的 telnet 窗口。
我可以在指定的服务器上使用 Thunderbird 毫无问题地发送/接收电子邮件。
【问题讨论】: