belongs to collection: PHP Miscellaneous
Here, we will demonstrate how we can send a text email message using the PHP program.
The source code to send a text e-mail message is given below. The given program is compiled and executed successfully.
//PHP program to send a text message using e-mail.
$header = "From:firstname.lastname@example.org \r\n";
$to = "email@example.com";
$sub = "Subject of the mail";
$msg = "Hello message from email";
$isSuccess = mail($to, $sub, $msg, $header);
if ($isSuccess == true)
printf("Email send successfully");
printf("Email sending failed");
If you pass the correct e-mail addresses then
it will print a "Email send successfully" message on the webpage.
In the above program, we created local variables that are initialized with the following values:
$isSuccess = mail ($to,$sub,$msg,$header);
Here, we used the mail() method, which is used to send a text email message and return the boolean value true or false. The mail() message returns true if the email sends successfully otherwise it returns false.
total answers (1)
start bookmarking useful questions and collections and save it into your
own study-lists, login now to start creating your own collections.