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: "[email protected],[email protected]",
from: "[email protected]",
subject: "Some Automated Email",
body: "<strong>Lorem Ipsum</strong>",
isBodyHtml: true
);
I've tried a few scenarios:
[email protected];[email protected]
No emails recieved: An invalid character was found in the mail header: ';'.
[email protected]; [email protected]
Only the first recipient receives the email
[email protected],[email protected]
both recieved the email
[email protected], [email protected]
both recieved the email
[email protected], [email protected]
First recieved the email, but uncaught exception: Mailbox unavailable. The server response was: 5.7.1 Unable to relay
[email protected], [email protected]
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 [email protected],[email protected]
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.