Plesk проблема отправки электронной почты из .Net REST API - PullRequest
0 голосов
/ 31 января 2019

У меня есть REST Api на моем выделенном Windows Server 2016 с использованием Onyx Plesk - company = 1and1.com.

Вот мой код:

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 Ответ

0 голосов
/ 31 января 2019

Вам необходимо добавить smtp.EnableSsl = true;, который уже прокомментирован в вашем коде.Попробуйте раскомментировать.

...