I'm using a 3rd party SMTP service for sending my newsletters. Because of that, my ISP does not accept bounces because they are coming from an email not originating with them. Okay. So I set up a mailbox with my SMTP service to accept the bounces.
However, my mailing list program is refusing to send out emails whose return-path has a different domain than the from field.
I believe this is caused by phpmailer in it's mailsend routine:
The key code appears to be this, but I'm not that much of an expert with PHP to figure out how to get around whatever check it is doing, which I think has something to do with that safe_mode. The return-path value that I want to use is in the variable: $this->Sender
/**
* Sends mail using the PHP mail() function.
* @param string $header The message headers
* @param string $body The message body
* @access protected
* @return bool
*/
protected function MailSend($header, $body) {
$toArr = array();
foreach($this->to as $t) {
$toArr[] = $this->AddrFormat($t);
}
$to = implode(', ', $toArr);
$params = sprintf("-oi -f %s", $this->Sender);
if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$ body);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$b ody);
}
} else {
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$ body);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
// implement call back function if it exists
$isSent = ($rt == 1) ? 1 : 0;
$this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$b ody);
}
}
if (isset($old_from)) {
ini_set('sendmail_from', $old_from);
}
if(!$rt) {
throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL);
}
return true;
}
Does anyone know what in this code is preventing me from using a different domain for my return-path, or better yet, does anyone know how I can fix (or hack) this so it will send out my mail?
@Sanmai's comment got me looking at the parameters. When I started testing some of them in the phpmailer routine, I found the code wasn't executed. So at least he helped me realize the problem's somewhere else.
I still have the problem. I'll now try to better isolate it. Then maybe I can solve it, and if not, I'll modify this question and try again.
Thanks for giving me a bit of something to go on.