C# - 从BlueHost发送电子邮件

时间:2012-05-07 19:30:03

标签: c# email smtp bluehost

我有BlueHost,我无法使用C#。我已经从我登录的页面中获取了详细信息:

enter image description here

然后我使用此代码尝试发送电子邮件:

MailMessage message = new MailMessage
{
    From = new MailAddress("toEmail@site.com", "toEmail@site.com")
};
message.IsBodyHtml = false;
message.To.Add("email@site.com");
message.Subject = "my subject";
message.Body = "body";
message.Priority = MailPriority.Normal;
SmtpClient client = new SmtpClient
{
    Port = 465,
    Host = "box263.bluehost.com",
    EnableSsl = true,
    Credentials = new NetworkCredential("myEmail@site.com", "myPassword"),
    Timeout = 10000,
    UseDefaultCredentials = false
};
client.Send(message);

即使它有足够的时间(10秒),也会抛出一个错误,表示它超时。即使我没有设置超时时间,它也只是坐了一会儿。我也尝试过没有SSL,禁用'EnableSsl',将端口更改为'26',并将主机更改为'mail.embirk.com',但这也不起作用。此外,这适用于第三方软件,如Microsoft Outlook和东西。有任何想法吗?感谢。

修改 我还联系了Bluehost的二级支持技术人员,他们说他们也很难过。他们说他们用Thunderbird尝试过,这一切都奏效了。他们说可能正在寻找证书?

编辑2:

这个Outlook注册表是否有帮助。 (如果运行,这适用于Outlook。)

REGEDIT4

[HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\OMI Account Manager\Accounts\steve@embirk.com]
"DCEmail"=dword:00000002
"IMAP Server"="box263.bluehost.com"
"IMAP Port"=dword:000003e1
"SMTP Server"="box263.bluehost.com"
"SMTP Port"=dword:000001d1
"Connection Type"=dword:00000003
"IMAP User Name"="steve@embirk.com"
"SMTP Display Name"="steve@embirk.com"
"SMTP Email Address"="steve@embirk.com"
"SMTP Reply To Email Address"="steve@embirk.com"
"SMTP Organization Name"=""
"Account Name"="steve@embirk.com"
"IMAP Timeout"=dword:0000003c
"SMTP Timeout"=dword:0000003c
"IMAP Secure Connection"=dword:00000001
"IMAP Skip Account"=dword:00000000
"IMAP Prompt for Password"=dword:00000001
"SMTP User Name"="steve@embirk.com"
"SMTP Use Sicily"=dword:00000002
"SMTP Secure Connection"=dword:00000001
"SMTP Split Messages"=dword:00000000
"SMTP Prompt for Password"=dword:00000000
"IMAP Root Folder"=""
"IMAP Polling"=dword:00000001
"IMAP Poll All Folders"=dword:00000001
"IMAP Dirty"=dword:00000000

1 个答案:

答案 0 :(得分:0)

我会尝试在客户端块之外声明凭据并将其分配给客户端凭据。

实际上完全摆脱了阻止。

NetworkCredential myCred = new NetworkCredential("xxxxxxxx", "xxxxxxxx");


client.Credentials = myCred;
client.port = 465,
client.Host = "box263.bluehost.com",
client.EnableSsl = true,
client.Credentials = new NetworkCredential("myEmail@site.com", "myPassword"),
client.Timeout = 10000,
client.UseDefaultCredentials = false