To send emails with PHP, use the mail() function. For complete information about this function, visit https://www.php.net/manual/en/ref.mail.php

Here’s an example of sending emails with PHP.

<?php

// Assign the recipient's address
$destination = "recipient_name@domain.com";

// Assign the sender's address
$sender = "From:sender_name@domain.com\r\nReply-To:sender_name@domain.com\r\n";

// Message Subject
$subject = "Message Sending Test";

// Message Text
$message = "This is a message sending with PHP";

if ( mail($destination, $subject, $message, $sender) )  echo "The message has been sent successfully";
else  echo "The message has not been sent successfully";

?>

 

In the $sender variable assignment, you can specify all the sending data (From, ReplyTo, Bcc, Bcco).

The values for the addresses “account_name@domain_name.xxx“, “account_name2@domain_name.xxx“, and “account_name3@domain_name.xxx” can be the same or different.