Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

5.7.1 Client does not have permissions to send as this sender

$
0
0

Hi,

I'm using C# to send mail , the situation is i don't want the receiver see the real mailaddress from me.

my code as below:

Step 1 : create new instance of MailMessage

                MailMessage message = new MailMessage();
                message.From = new MailAddress("mockAddress@hotmail.com"); //this the mock address  receiver will see
                message.Subject = subject;
                message.Body = body;
                message.BodyEncoding = Encoding.UTF8;

Step2:

                SmtpClient smtp = new SmtpClient("smtp.office365.com");
                smtp.UseDefaultCredentials = false;
                smtp.Credentials = new NetworkCredential("admin@onmicrosoft.com", "password"); //this is the real mailAddress used to credential.
                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtp.Port = 587;
                smtp.EnableSsl = true;
                smtp.Send(message);

once i run the code, there is an error shows:

5.7.1 Client does not have permissions to send as this sender

if i change mailAddress "mockAddress@hotmail.com" to "admin@onmicrosoft.com", it works.

the real situation is receiver can not see real mailaddress from sender.

Expect  to your reply!!


Viewing all articles
Browse latest Browse all 7132

Trending Articles