Here we are solving a basic problem faced by a beginner web developer in PHP i.e. Send email using PHP
// multiple recipients
$to = "email@example.com,firstname.lastname@example.org";
$subject = "Survey";
$message = "HELLO";
// To send HTML mail, the Content-type header must be set
$headers = "From: me <myMail@gmail.com>";
// Mail it
if(mail($to, $subject, $message, $headers))
echo "Sent mail";
echo "mail not sent";
The mail() function allows you to send emails directly from a script.
Receiver, or receivers of the mail.
Some examples are:
User , Another User
Subject of the email to be sent.
Message to be sent.
Each line should be separated with a CRLF (\r\n). Lines should not be larger than 70 characters.
4) additional_headers (optional)
String to be inserted at the end of the email header.
This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n).
If outside data are used to compose this header, the data should be sanitized so that no unwanted headers could be injected.
5) additional_parameters (optional)
The additional_parameters parameter can be used to pass additional flags as command line options to the program configured to be used when sending mail,
as defined by the sendmail_path configuration setting.
For example, this can be used to set the envelope sender address when using sendmail with the -f sendmail option.