Hi,
WAMP does not have to come with an SMTP server for the PHP function mail() to be able to send messages through a relaying server. The mail() function works happily, passing the email messages to the SMTP server specified in the php.ini file.
Here is an example of a function that is being called from a scheduled command line script to inform the webmaster that the daily database backup has finished:
<?php
/**
* @20070908
toivo@totaldata.biz send mail - adapted from examples on the net
*/
function sendEmail($to, $subject, $message, $from = NULL, $reply_to = NULL, $cc = NULL) {
// build headers
$headers = "";
if ($cc) {
$headers .= "Cc: " . $cc . "\r\n";
}
if ($from) {
$headers .= "From: " . $from . "\r\n";
}
if ($reply_to) {
$headers .= "Reply-To: " . $reply_to . "\r\n";
}
$headers = "X-Mailer: PHP/" . phpversion();
// max 70 characters per line
$message = wordwrap($message, 70);
// windows and full stop on the start of a line
$message = str_replace("\n.", "\n..", $message);
// send mail
if (mail($to, $subject, $message, $headers)) {
$status = "mail was sent to $to";
} else {
$status = "mail could not be sent to $to";
}
return $status;
}
?>
toivo
Sydney, Australia