How to email in PHP
Moderator: General Moderators
-
johnsonzhang
- Forum Newbie
- Posts: 3
- Joined: Sun Apr 06, 2003 5:33 am
- Contact:
How to email in PHP
who can help me ?i'm a newbie in PHP. i'd like to know how to send an email in PHP?tell me more about it.thank you
with the mail()function.
Here is an example of the proper syntax:
Here is how to send HTML email:
Also, your server must have a proper smtp connection.
Here is an example of the proper syntax:
Code: Select all
<?php
$subject = "urgent!!";
$msg = "hello\n\n just testing";
$header = "From: "johnsonzhang" <johnsonzhang@yoursite.com>";
if(mail($to, $subject, $msg,$header)) {
echo "Mail Sent";
} else {
echo "Mail Not Sent" ;
}
?>Here is how to send HTML email:
Code: Select all
<?php
$to = "johnsonzhang@yoursite.com";
$subject = "Test";
$message ='Testing
<br><br><br>
<img src=http://www.devnetwork.net/forums/templates/subSilver/images/logo_phpBB.gif>';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Sam <mahamedf@telusplanet.net>\r\n";
if(mail($to, $subject, $message,$headers)) {
echo "Mail Sent";
} else {
echo "Mail Not Sent" ;
}
?>