GoDaddy的SMTP发送邮件的问题及解决方法

采用Asp.net通过SMTP发送邮件时,会受到服务器限制,需要通过relay-hosting.secureserver.net来发送。

private bool sendMail()
    {
        try
        {
            MailAddress from = new MailAddress("Ur email address applied from GoDaddy.");
            MailAddress to = new MailAddress("The email address you will send to.");
            MailMessage message = new MailMessage(from, to);
            message.Subject = subject;
            message.Body = body;
            SmtpClient client = new SmtpClient("relay-hosting.secureserver.net", 25); //这里不是smtpout.secureserver.net
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.Credentials = CredentialCache.DefaultNetworkCredentials; //无需用户名密码
            client.Send(message);

            return true;
        }
        catch (System.Exception ex)
        {
            lbNotes.Text = ex.ToString();
            return false;
        }
    }
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/donhao/article/details/6881985
文章标签: asp.net email 服务器
个人分类: ASP.net C#
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭