note 62088 deleted from ref.mail by didou
| From: | didou@php.net | Date: | Sun, 23 Apr 2006 22:43:20 +0000 |
| Subject: | note 62088 deleted from ref.mail by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109217@lists.php.net to get a copy of this message | ||
Note Submitter: Anthony Catel (paraboul at gmail . com)
----
<?php
function smail($to, $sujet, $msg, $from, $pattern = false) {
if (is_file($msg) && is_array($pattern)) {
foreach ($pattern as $key => $output) {
$base[] = $key;
$bnew[] = $output;
}
$fd = @fopen($msg, "r");
while (!feof($fd)) {
$line = fgets($fd, 2048);
$content .= str_replace($base, $bnew, $line);
}
fclose($fd);
} else {
$content = $msg;
}
mail($to, $sujet, $content,
"From: $from\r\n"
."Reply-To: $from\r\n"
."X-Mailer: PHP/" . phpversion());
}
$pattern['LOGIN'] = 'toto';
$pattern['NAME'] = 'beber';
smail('toto@mail.com', 'Hi!', 'hi.txt', 'me@mail.com',
$pattern);
?>
Send mail with specify a file and replace occurence :
hi.txt :
Hello LOGIN
Your name is NAME
bye