问题
I want to send NewsLetter Emails to users.
I have done like this:
public ActionResult SendNewsLetter()
{
_userMailer.NewsLetter().Send();
return View();
}
and in userMailer class:
public virtual MvcMailMessage NewsLetter(string userEmail)
{
//ViewBag.Data = someObject;
return Populate(x =>
{
x.Subject = "NewsLetter";
x.ViewName = "NewsLetter";
x.To.Add("hello@mydomain.mobi");
x.Bcc.Add(userEmail);
});
}
I add submitted newsletter emails to bcc.
but when I send it I encounter this issue:
Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.
if remove bbc I can send email normaly because I have provided authentications for hello@mydomain.mobi in web.config.
<system.net>
<mailSettings>
<!-- Method#1: Configure smtp server credentials --><smtp deliveryMethod="Network" from="hello@mydomain.com">
<network host="mydomain.com" port="25" userName="hello@mydomain.com" password="123456" enableSsl="false" />
</smtp>
</mailSettings>
but Im amazed why I cannot send email to other emails?
does somebody have any idea?
回答1:
The error message that you're encountering isn't related to MVCMailer at all. I'd contact the system administrator of the SMTP server you're attempting to use and see if you're allowed to use the hello@mydomain.com
user that you're authenticating with to send email to the value of userEmail
. A lot of SMTP servers that web servers use will often have limits or restrictions on email to prevent spamming.
来源:https://stackoverflow.com/questions/22897411/mail-server-requires-authentication-when-attempting-to-send-to-a-non-local-e-mai