The source code to send a text e-mail message is given below. The given program is compiled and executed successfully.
<?php
//PHP program to send a text message using e-mail.
ini_set("sendmail_from", "testmail@includehelp.com");
$header = "From:testmail@includehelp.com \r\n";
$to = "reciever@gmail.com";
$sub = "Subject of the mail";
$msg = "Hello message from email";
$isSuccess = mail($to, $sub, $msg, $header);
if ($isSuccess == true)
{
printf("Email send successfully");
}
else
{
printf("Email sending failed");
}
?>
Output:
If you pass the correct e-mail addresses then
it will print a "Email send successfully" message on the webpage.
Explanation:
In the above program, we created local variables that are initialized with the following values:
From email address
To email address
Header
Subject
Message
$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.
Program/Source Code:
The source code to send a text e-mail message is given below. The given program is compiled and executed successfully.
Output:
Explanation:
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.
need an explanation for this answer? contact us directly to get an explanation for this answer