电子邮件发送失败(asp.net)

时间:2016-04-20 09:35:32

标签: c#-4.0

这是一封发送电子邮件的代码......它在我的计算机上工作得非常好,但是当我在godaddy服务器上传此代码时无效。

这是我得到的错误

连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应173.194.205.108:587

(您需要为您的特定网络框架下载EASendMail.dll才能使此代码正常工作)

    SmtpMail oMail = new SmtpMail("TryIt");
    EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();

    // Your gmail email address
    oMail.From = "SendersAddress@gmail.com";


    // Set recipient email address
    oMail.To = "Recieverseaddress@gmail.com";

    // Set email subject
    oMail.Subject = "Verification Code";

    // Set email body
    oMail.TextBody = "This is a test code";


    // Gmail SMTP server address
    SmtpServer oServer = new SmtpServer("smtp.gmail.com");

    // Set 25 port, if you want to use 587 port, please change 25 5o 587
    oServer.Port = 587;

    // detect SSL/TLS automatically
    oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

    // Gmail user authentication
    // For example: your email is "gmailid@gmail.com", then the user should be the same
    oServer.User = "Sendersaddress@gmail.com";
    oServer.Password = "Password";

    try
    {
        Messagebox("start to send email over SSL ...");
        oSmtp.SendMail(oServer, oMail);
        Response.Redirect("~/Verification.aspx");
    }
    catch (Exception ep)
    {
        Messagebox("failed to send email with the following error:");
        Messagebox(ep.Message);
    }

0 个答案:

没有答案
相关问题