Here we are solving a basic problem faced by a beginner web developer in PHP i.e. Send email using PHP .

Sample code

<?php

    // multiple recipients
    $to  = "someexample@gmail.com,someotherexample@gmail.com";
    // subject
    $subject = "Survey";
    // message
    $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";
    }
    else
    {
        echo "mail not sent";
    }
?>

The mail() function allows you to send emails directly from a script.

Syntax

mail(to,subject,message,headers,parameters);

Parameters

1) to

Receiver, or receivers of the mail.
Some examples are:
user@example.com
user@example.com, anotheruser@example.com
User
User , Another User


2) subject

Subject of the email to be sent.

3) message

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.