Send mail in
PHP
If you want to start a image hosting business read the following
lesson first:
This lesson shows how to send mail by PHP.
Send HTML mail
Assume you have opened image hosting business, like the lesson image
hosting business in minutes. After user insert an image, you want
to send your client email about the retrieving url and its image in
HTML style.
You may use the following sendMail.php to fulfill this task.
<?php
//get user email
$to =$_GET['email'];
$imageid=$_GET['id'];
// subject
$subject = 'Image saving receipt';
// message
$message = "<html>".
"<head>".
" <title>Image saving receipt</title>".
"</head>".
"<body>".
"<img src=\"http://www.yoursite.com/script.php?id=$imageid\">".
"<br>Your image url is http://www.yoursite.com/script.php?id=$imageid".
"</body>".
"</html>";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Image saving <yourname@yoursite.com>'
. "\r\n";
// Mail it
mail($to, $subject, $message,$headers);
?>
|
In the above code, HTML header must be set for HTML mail. If you
don't set header, you just send a plain text file by calling mail($to,$subject,$message).
Here is how to use sendMail.php. Suppose after your saving script
saved image into database(see the lesson image
hosting business in minutes for the detail), just call sendMail.php?email=test@example.com&id=24 .
This is assume saved image's id =24 and you know the client email
address.
|
| |