PHP Mail

mail() - Send mail

This function is used to send email. You can send text, html message and attachment with message using this function.

bool mail (string $filename, string $to,  string $subject,  string $message [,  string $additional_headers [,  string $additional_headers ]] ) 


  • to: Receiver, or receivers of the mail.
    • User <>
    • User <>, Another User <>
  • subject: Subject of the email to be sent.
  • messagel: Message to be sent.
    Each line should be separated with a CRLF (rn). Lines should not be larger than 70 characters.
  • 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 (rn). If outside data are used to compose this header, the data should be sanitized so that no unwanted headers could be injected.
  $to ="";
  $subject = "the subject";
  $message = "hello";
  $headers = 'From:' . "rn" .
  'Reply-To:' . "rn" .
  'X-Mailer: PHP/' . phpversion();
  mail($to, $subject, $message, $headers);