Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send email as an AD group

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?

like image 780
NS.X. Avatar asked Nov 12 '22 19:11

NS.X.


1 Answers

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.

like image 77
Mike Beeler Avatar answered Nov 14 '22 21:11

Mike Beeler