Sending email from PHP using mail().
- July 22nd, 2013
- Posted in Documentation
- Write comment
To send text email from PHP:
tomailaddress‘;
$from = ‘frommailaddress‘;
$subject = ‘Here is my subject.’;
$message = ‘Some text in the body of the message.’;$headers .= ‘X-Priority:1 (Highest)’ . “\r\n”;
$headers .= ‘From: ‘ . $from . “\r\n”;
mail( $to, $subject, $message, $headers) or print ‘Could not send mail’;
?>
To send HTML email from PHP:
tomailaddress‘;
$from = ‘frommailaddress‘;
$subject = ‘Here is my subject.’;
$message = ‘
<HTML>
<BODY>
<B>
Some bold text
</B>
<P>
Some other HTML stuff.
</BODY>
</HTML>
‘;$headers = ‘MIME-Version: 1.0’ . “\r\n”;
$headers .= ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
$headers .= ‘X-Priority:1 (Highest)’ . “\r\n”;
$headers .= ‘From: ‘ . $from . “\r\n”;
mail( $to, $subject, $message, $headers) or print ‘Could not send mail’;
?>
No comments yet.