Reputation: 513
I'm sending email to a distribution list using System.Net.Mail.SmtpClient Here is the method I use. [email protected] is the distribution list.
var strMailServer = ConfigurationManager.AppSettings["MailServer"];
var fromAddress = new MailAddress("[email protected]");
var bodyMsg = "BodyText;
var message = new MailMessage();
var smtpClient = new SmtpClient(strMailServer)
{
Credentials = new NetworkCredential("", ""),
Port = 25,
EnableSsl = true
};
message.From = fromAddress;
message.To.Add("[email protected]");
message.Subject = _context.Fields["Subject"].Value;
message.IsBodyHtml = true;
message.Body = bodyMsg;
smtpClient.Send(message);
The mail is not delivered to [email protected] distribution list. Am I missing something?
Upvotes: 3
Views: 5380
Reputation: 513
When creating the distribution list, uncheck "Require that all senders are authenticated"
Upvotes: 4
Reputation: 4808
If you are using a username and password other than your windows credentials, you need to set UseDefaultCredentials
to false before providing the new credentials:
var smtpClient = new SmtpClient(strMailServer)
{
UseDefaultCredentials = false,
Credentials = new NetworkCredential("", ""),
Port = 25,
EnableSsl = true
};
Upvotes: 1