To send email in PHP, we use mail() function. You can send text message, html message and attachment with message by the use of PHP mail() function.
Syntax
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )
$to specifies receiver or receivers of the mail. The receiver must be specified one of the following forms.
user@example.com
user@example.com, anotheruser@example.com
User user@example.com
User user@example.com
$subject
represents subject of the mail.
$message
represents message of the mail to be sent.
PHP mail Example
<?php
$to = "pranav.chhabra456@gmail.com";
$subject = "This is subject";
$message = "This is simple text message.";
$header = "From:mukesh.tomar@evontech.com \r\n";
$result = mail ($to,$subject,$message,$header);
if( $result == true ){
echo "Message sent successfully...";
}else{
echo "Sorry, unable to send mail...";
}
?>
0 Comment(s)