Use the PHP function mail() to send an email message from a PHP script.
The first parameter of the mail() function is the email address to send the email message to.
Assuming that you are running your PHP script on the server that is the MTA for the example.com email domain, and that there is a local user called fred, all of these are valid email addresses:
Sending an Email to More Than One Recipient
The MTA thinks you are trying to send an email to the local user fred.
This is the normal form for an email address, and the one that you are probably most familiar with.
- fred @ example.com
The MTA will automatically collapse the whitespace in the email address.
Although perfectly legal, email addresses with whitespace are seldom seen today.
- "Fred Bloggs" <firstname.lastname@example.org>
The MTA will automatically extract the email@example.com from between the angular brackets.
The entire string will be added as is to the From: line of the email message.
Note that the double quotes are importantódo not leave them out.
Add additional addresses to the to parameter. Separate them by a comma and a space:
fred, firstname.lastname@example.org, "Jane Doe"
If you want to cc: or bcc: an email to someone, do this by adding additional headers to your email.
Please check back next week for the conclusion of this article.