54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
|
<?php
|
||
|
|
||
|
require $phpmail_path;
|
||
|
|
||
|
function send_mail($from,$to,$subject,$msg,$headers=array()) {
|
||
|
global $mail_send_method, $mail_hearders, $mail_send_params, $mail_sender, $mail_catch;
|
||
|
$mail_obj = & Mail::factory($mail_send_method, $mail_send_params);
|
||
|
|
||
|
if(is_array($mail_hearders)) {
|
||
|
$headers = array_merge($headers,$mail_hearders);
|
||
|
}
|
||
|
|
||
|
if ($subject) {
|
||
|
$headers["Subject"] = $subject;
|
||
|
}
|
||
|
|
||
|
if ($from) {
|
||
|
$headers['From'] = $from;
|
||
|
}
|
||
|
else {
|
||
|
$headers['From'] = $mail_sender;
|
||
|
}
|
||
|
|
||
|
if ($mail_catch) {
|
||
|
$headers["To"] = $mail_catch;
|
||
|
$headers["X-Orig-To"] = $to;
|
||
|
$to=$mail_catch;
|
||
|
}
|
||
|
else {
|
||
|
$headers["To"] = $to;
|
||
|
}
|
||
|
|
||
|
$to = array (
|
||
|
'To' => $to
|
||
|
);
|
||
|
|
||
|
foreach(array_keys($headers) as $header) {
|
||
|
if(strtoupper($header) == 'BCC') {
|
||
|
$to['BCC'] = $headers[$header];
|
||
|
}
|
||
|
elseif(strtoupper($header) == 'CC') {
|
||
|
$to['CC'] = $headers[$header];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$ret = $mail_obj -> send($to,$headers,$msg);
|
||
|
|
||
|
if ($ret instanceof PEAR_Error) {
|
||
|
logging('ERROR',"Error sending email to $to : ".$ret -> getMessage());
|
||
|
return -1;
|
||
|
}
|
||
|
return true;
|
||
|
}
|