移动到新服务器后ASP Mail功能无法正常工作

时间:2012-03-14 09:00:15

标签: asp.net forms email mail-server

这曾经在旧服务器上运行,我备份了文件并让系统在新服务器上运行。数据库都是完整且连接的,文件都在那里,但每当用户想要注册时,他们都会收到“发送邮件失败”错误。

这是注册文件中处理激活邮件发送的行:

                MailClass.MailGonder("info@mysite.com", TxtEMail.Text, "Aktivasyon Kodu", body, "info@mysite.com", "mypasswordishere", "mail.mysite.com", 587);

这是Mail_Class.cs文件,我非常肯定会处理整个邮件:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Net;

namespace Sngl
{
public class MailClass
{
public MailClass() { }

public static void MailGonder(string kimden, string kime, string title, string body, string senderEmail, string senderPassword, string smtpServer, int port)
{
    try
    {
        System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage(kimden, kime, title, body);
        MyMailMessage.IsBodyHtml = true;
        MyMailMessage.Priority = System.Net.Mail.MailPriority.High;
        System.Net.NetworkCredential mailAuthentication = new
        System.Net.NetworkCredential(senderEmail, senderPassword);
        System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient(smtpServer, port);
        mailClient.EnableSsl = false;
        mailClient.UseDefaultCredentials = false;
        mailClient.Credentials = mailAuthentication;
        mailClient.Send(MyMailMessage);

        PropertyClass.Result = true;

    }
    catch (Exception ex)
    {
        PropertyClass.Result = false;
        PropertyClass.Message = ex.Message;
    }
}
}
}

1 个答案:

答案 0 :(得分:0)

在尝试了所有建议之后,我很确定问题出在服务器上,因为旧服务器上的设置相同。我重复了几次,但仍然没有。等待来自webhost支持的回答。