none
Error in programmatically sending mail on behalf of a non-existent email address RRS feed

  • Question

  • Hi,

    We use System.Net.Mail.SmtpClient class in C# to send mails using an Exchange 365 mailbox. This is the outline of the code:

    System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();

    smtpClient.UseDefaultCredentials = false;

    smtpClient.Credentials = new System.Net.NetworkCredential("Valid O365 Exchange User Email address", "Password");

    smtpClient.Port = 587;

    smtpClient.Host = "smtp.office365.com";

    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

    smtpClient.EnableSsl = true;

    .............

    MailMessage msg = new MailMessage();

    msg.From = new MailAddress("noreply@abc.com");   // non-existent mailbox address
    msg.Sender = new MailAddress("userEmail@xyz.com");  // Valid O365 user used in credentials above

    ..............

    // add subject, body etc. and send

    This was working till recently and in the received mail we used to see sender as "noreply@abc.com on behalf of userEmail@xyz.com".

    However, this has stopped working recently and we are getting error. There is no change in code or the exchange configuration. Please let us know if this is due to any recent change and what is the possible fix for this error:

    System.Net.Mail.SmtpException: Transaction failed. The server response was: 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message

    Thanks


    Prakash Arya www.crowcanyon.com

    Tuesday, February 26, 2019 6:11 AM

All replies

  • SRS is the most recent change to Office365 Transport stack https://support.microsoft.com/en-au/help/4490129/sender-rewriting-scheme-srs-in-office-365

    What you doing to me looks very spammy (even if you have a valid use) so I'm surprised it ever worked. Maybe explain why you want to do this and somebody can suggest a better alternative given the available technology and API's available in Office365 as trying to continue with the above even if you find a workaround looks like a pretty fragile process that will break in the future.

    Cheers
    Glen

    Wednesday, February 27, 2019 5:19 AM
  • Hi Glen,

    Thanks for your response. We have a help desk product and we send mails to people submitting the requests. Some of these mails are sent from a generic address like no-reply@xxxx.com. There is no reply expected for these mails.

    Earlier this used to work with from shown as "mailbox on behalf of no-reply" but this doesn't work anymore. If we have a valid email address and we give on behalf permissions then of course this works. We just want to see if this can work for non-existent mail address.

    Thanks.


    Prakash Arya www.crowcanyon.com

    Wednesday, February 27, 2019 12:04 PM
  • So from a business process point of view what is the advantage of having a non-existent email address?. If somebody does reply to that they will get a NDR which are generally user unfriendly and doesn't tell the recipient why the action that they took was invalid which in tern could lead to a help desk call. From the business point of view all of this is costly in terms of lost productivity and wasting peoples time, why not have a valid address and then use an AutoReply rule on it so if somebody does intentionally or unintentionally reply to it they will get a well worded response that this isn't a valid address and the process they should follow to followup on their inquire.   

    >>Earlier this used to work with from shown as "mailbox on behalf of no-reply" but this doesn't work anymore. If we have a valid email address and we give on behalf permissions then of course this works. We just want to see if this can work for non-existent mail address.

    If the email address wasn't assigned then you shouldn't have got the above so it also maybe a bug that was closed or the address was really assigned and somebody deleted it. You could track that down by looking a the mapi  properties of the message that didn't previously work.

    Cheers
    Glen

     


    Wednesday, February 27, 2019 11:29 PM