In .NET, can I send email using the identity of an AD group that I own?
My current code:
using (var smtp = new SmtpClient("smtp.somecompany.com"))
{
smtp.Credentials = CredentialCache.DefaultNetworkCredentials;
var mail = new MailMessage("[email protected]", recipients)
{
...
};
smtp.Send(mail);
}
And I'm getting
System.Net.Mail.SmtpException: Mailbox unavailable. The server response was: 5.7.1 Client does not have permissions to send as this sender
I know I can send as a different user by using
smtp.Credentials = new NetworkCredential(...)
and pass name/password pair.
However, an AD group does not have a password, and I don't think the group alias even count as a user name.
So is it possible to send email as the group at all?
AD groups are security objects, and not directly related to email. If for example you had a development group and you wanted anyone in the dev group to access the mailbox, with exchange it's possible to set up a shared mailbox that anyone in the AD group can access. It is also possible to set the outgoing address for that mailbox to be [email protected].
When you have created the shared mailbox using the code in your example would work correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With