I'm writing a registration script that uses PEAR:Mail. It's not talking to my local SMTP server properly:
"127.0.0.1" "RECEIVED: RCPT TO:<@localhost>"
No matter what variables I send to it, it still sends that borked RCPT TO: line.
Here's the function I wrote:
function sendmail ($from, $to, $body, $subject='Email from vCMS') {
$to=$recipient;
require('Mail.php'); //relies on PEAR:Mail
require('config/vars.php'); //global variable file
$servertype = $email['servertype'];
if ($servertype=='smtp') {
$headers["From"] = $from;
$headers["Subject"] = $subject;
$mail_object =& Mail::factory("smtp",$params);
$mail_object->send($recipient, $headers, $body);
}
if ($servertype=='mail') {
$headers["From"] = $from;
$headers["Subject"] = $subject;
$mail_object =& Mail::factory("mail");
$mail_object->send($recipient, $headers, $body);
}
if ($servertype=='sendmail') {
/*$params["sendmail_path"] -
The location of the sendmail program on the filesystem.
Default is /usr/bin/sendmail
$params["sendmail_args"] -
Additional parameters to pass to the sendmail program.
*/
$headers["From"] = $from;
$headers["Subject"] = $subject;
$mail_object =& Mail::factory("sendmail");
//$mail_object =& Mail::factory("sendmail","$params");
$mail_object->send($recipient, $headers, $body);
}
}
?>
Here's vars.php:
<? $vcms_url='http://technopasta.no-ip.com:7890/';
//variables (that can be) used by funcs/vmail.php
$email['servertype']='smtp';
$params['host']='localhost';
//needed for SMTP only
$email['auth']=false;
$params['port']=25;
//$email['username']='Admin';
//$params['password']='tester';
$params['localhost']='10.0.0.3';
$email['admin_email']='voltagex@gmail.com';
/*type of user registration,
auth (requiring admin approval) or
confirm (sends user a verification link)*/
$regtype='confirm' ?>
And it all gets called in my registration script:
...
sendmail($email['admin_email'],$user_email,$body,'vCMS: New User');
...
All the variables there are being set correctly.
WTF is going on?