代码之家  ›  专栏  ›  技术社区  ›  Robert Green MBA

Plesk问题从.Net REST API发送电子邮件

  •  0
  • Robert Green MBA  · 技术社区  · 6 年前

    这是我的代码:

    fromEmail = "fromEmail@gmail.com";
    toEmail = "toEmail@gmail.com";
    subject = "test-subject";
    message = "test-message";
    bccEmail= "bccEmail@gmail.com";
    
    MailMessage mailMessage = new MailMessage(fromEmail, toEmail, subject, message);
    mailMessage.Bcc.Add(bccEmail);
    mailMessage.IsBodyHtml = true;
    SmtpClient smtp = new SmtpClient("smtp.1and1.com", 587);
    //smtp.EnableSsl = true;
    NetworkCredential credentials = new NetworkCredential(WebConfigurationManager.AppSettings["EmailUserName"], WebConfigurationManager.AppSettings["EmailPassword"]);
    smtp.Credentials = credentials;
    smtp.Send(mailMessage);
    

    我有一个 200 从我的服务,但我收到了以下来自Plesk的电子邮件(注意“$”前的收件人,主题和消息(我认为这是问题,但不确定为什么它这样做)。此外,此代码在本地工作正常-在调试中并在本地IIS上运行):

        Could not deliver message to the following recipient(s):
    
        Failed Recipient: $toEmail@gmail.com
        Reason: Remote host said: 550 5.1.1 The email account that you tried to reach does not exist. Please try
        5.1.1 double-checking the recipient's email address for typos or
        5.1.1 unnecessary spaces. Learn more at
        5.1.1  https://support.google.com/mail/?p=NoSuchUser
    
    
           -- The header and top 20 lines of the message follows --
    
        Received: from ma...net (mai...p.net [1...9]) by gw...w.net with SMTP;
           Wed, 30 Jan 2019 19:11:39 -0800
        Received: from WIN5101 (WI...et [10.10.28.159]) by mail...et with SMTP;
           Wed, 30 Jan 2019 19:11:30 -0800
        MIME-Version: 1.0
        To: $toEmail@gmail.com
        Date: 30 Jan 2019 19:11:30 -0800
        Subject: $test-subject
        Content-Type: text/plain; charset=us-ascii
        Content-Transfer-Encoding: quoted-printable
        X-Declude-RefID: 
        X-Declude-Note: Scanned by Declude 4.12.11
        X-Declude-Scan: Outgoing Score [5] at 19:11:41 on 30 Jan 2019
        X-Declude-Tests: FILTER-SPAM [5]
        X-Country-Chain: 
        X-Declude-Code: e
        X-HELO: ma....w.net
        X-Identity: 1....9 | (Private IP) | gmail.com
    
        $test-message
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Nour    6 年前

    你需要添加 smtp.EnableSsl = true; 已经在你的代码中注释过了。尝试取消注释。