We've seen a few similar questions on StackOverflow before regarding System.Web.Helpers.Webmail.Send
but I see no proper explanation for what's going on.
Regarding the to:
parameter, the documentation says:
The email address of the recipient or recipients. Separate multiple recipients using a semicolon (;).
and I've seen answers saying "use a comma because the docs are wrong", or "use a semicolon", or "maybe it's an environment issue".
The code
WebMail.Send(
to: "joe.bloggs@mail.com,jane.bloggs@mail.com",
from: "no-reply@company.com",
subject: "Some Automated Email",
body: "<strong>Lorem Ipsum</strong>",
isBodyHtml: true
);
I've tried a few scenarios:
joe.bloggs@mail.com;jane.bloggs@mail.com
No emails recieved: An invalid character was found in the mail header: ';'.
joe.bloggs@mail.com; jane.bloggs@mail.com
Only the first recipient receives the email
joe.bloggs@mail.com,jane.bloggs@mail.com
both recieved the email
joe.bloggs@mail.com, jane.bloggs@mail.com
both recieved the email
joe.bloggs@mail.com, non-existant@mail.com
First recieved the email, but uncaught exception: Mailbox unavailable. The server response was: 5.7.1 Unable to relay
non-existant@mail.com, joe.bloggs@mail.com
No emails recieved: An invalid character was found in the mail header: ','.
Can anybody shed some light on this? I've actually had even more bizzare behaviour on a different server; I'm using Exchange for the above tests, but actually experienced different behaviour on hMailServer where joe.bloggs@mail.com,jane.bloggs@mail.com
resulted in a silent failure with no server errors and no outgoing mail in hMailServer logs. On the system with hMailServer I have only had success with a single address.