我使用 Onyx Plesk - company = 1and1.com 在我的专用 Windows Server 2016 上有一个 REST Api。
这是我的代码:
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