| Viewed 85 times

PHP how to send email


PHP how to send email

PHP
1 Answer
Mohammad Qandeel
Answered
9

I prefer to use built-in mail() function to send a simple email from PHP scripts.

you must have a web hosting account that allows you to use SMTP function

Example 

<?php
    $to      = 'any-email@example.com, any-email-2@example.com';
    $from    = "any-email@example.com";
    $subject = 'subject';
    $message = 'message body';
    $headers = 'From: '.$from ;

    mail($to, $subject, $message, $headers);
?>

don't forget to change ( from + to ) to real email address to successfully execute the PHP mail