*
* SMTP delivery backend for the Deliver class.
*
- * @copyright 1999-2016 The SquirrelMail Project Team
+ * @copyright 1999-2024 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
* @package squirrelmail
function preWriteToStream(&$s) {
if ($s) {
- if ($s{0} == '.') $s = '.' . $s;
+ if ($s[0] == '.') $s = '.' . $s;
$s = str_replace("\n.","\n..",$s);
}
}
global $use_smtp_tls,$smtp_auth_mech;
if ($authpop) {
- $this->authPop($pop_host, '', $user, $pass);
+ $this->authPop($user, $pass, $pop_host, '');
}
$rfc822_header = $message->rfc822_header;
$tmp = $this->parse_ehlo_response($stream);
if ($this->errorCheck($tmp,$stream)) {
// fall back to HELO if EHLO is not supported (error 5xx)
- if ($this->dlv_ret_nr{0} == '5') {
+ if ($this->dlv_ret_nr[0] == '5') {
fputs($stream, "HELO $helohost\r\n");
$tmp = fgets($stream,1024);
if ($this->errorCheck($tmp,$stream)) {
for ($i = 0, $cnt = count($to); $i < $cnt; $i++) {
if (!$to[$i]->host) $to[$i]->host = $domain;
if (strlen($to[$i]->mailbox)) {
- fputs($stream, 'RCPT TO:<'.$to[$i]->mailbox.'@'.$to[$i]->host.">\r\n");
+ // Ask for DSN if user has requested such and remote server supports it
+ if (isset($rfc822_header->dsn) && $rfc822_header->dsn
+ && array_key_exists('DSN',$this->ehlo)) {
+ // TODO: Make the DSN parameters configurable by admin? user?
+ fputs($stream, 'RCPT TO:<'.$to[$i]->mailbox.'@'.$to[$i]->host."> NOTIFY=SUCCESS,DELAY,FAILURE\r\n");
+ // Retry without DSN fields for cranky MTAs
+ if ($this->errorCheck($tmp, $stream)) {
+ fputs($stream, 'RCPT TO:<'.$to[$i]->mailbox.'@'.$to[$i]->host.">\r\n");
+ }
+ }
+ else
+ fputs($stream, 'RCPT TO:<'.$to[$i]->mailbox.'@'.$to[$i]->host.">\r\n");
$tmp = fgets($stream, 1024);
if ($this->errorCheck($tmp, $stream)) {
return(0);
for ($i = 0, $cnt = count($cc); $i < $cnt; $i++) {
if (!$cc[$i]->host) $cc[$i]->host = $domain;
if (strlen($cc[$i]->mailbox)) {
- fputs($stream, 'RCPT TO:<'.$cc[$i]->mailbox.'@'.$cc[$i]->host.">\r\n");
+ // Ask for DSN if user has requested such and remote server supports it
+ if (isset($rfc822_header->dsn) && $rfc822_header->dsn
+ && array_key_exists('DSN',$this->ehlo)) {
+ // TODO: Make the DSN parameters configurable by admin? user?
+ fputs($stream, 'RCPT TO:<'.$cc[$i]->mailbox.'@'.$cc[$i]->host."> NOTIFY=SUCCESS,DELAY,FAILURE\r\n");
+ // Retry without DSN fields for cranky MTAs
+ if ($this->errorCheck($tmp, $stream)) {
+ fputs($stream, 'RCPT TO:<'.$cc[$i]->mailbox.'@'.$cc[$i]->host.">\r\n");
+ }
+ }
+ else
+ fputs($stream, 'RCPT TO:<'.$cc[$i]->mailbox.'@'.$cc[$i]->host.">\r\n");
$tmp = fgets($stream, 1024);
if ($this->errorCheck($tmp, $stream)) {
return(0);
for ($i = 0, $cnt = count($bcc); $i < $cnt; $i++) {
if (!$bcc[$i]->host) $bcc[$i]->host = $domain;
if (strlen($bcc[$i]->mailbox)) {
- fputs($stream, 'RCPT TO:<'.$bcc[$i]->mailbox.'@'.$bcc[$i]->host.">\r\n");
+ // Ask for DSN if user has requested such and remote server supports it
+ if (isset($rfc822_header->dsn) && $rfc822_header->dsn
+ && array_key_exists('DSN',$this->ehlo)) {
+ // TODO: Make the DSN parameters configurable by admin? user?
+ fputs($stream, 'RCPT TO:<'.$bcc[$i]->mailbox.'@'.$bcc[$i]->host."> NOTIFY=SUCCESS,DELAY,FAILURE\r\n");
+ // Retry without DSN fields for cranky MTAs
+ if ($this->errorCheck($tmp, $stream)) {
+ fputs($stream, 'RCPT TO:<'.$bcc[$i]->mailbox.'@'.$bcc[$i]->host.">\r\n");
+ }
+ }
+ else
+ fputs($stream, 'RCPT TO:<'.$bcc[$i]->mailbox.'@'.$bcc[$i]->host.">\r\n");
$tmp = fgets($stream, 1024);
if ($this->errorCheck($tmp, $stream)) {
return(0);
$server_msg .= substr($line, 4);
}
- if ( ((int) $err_num{0}) < 4) {
+ if ( ((int) $err_num[0]) < 4) {
return false;
}
return true;
}
- function authPop($pop_server='', $pop_port='', $user, $pass) {
+ function authPop($user, $pass, $pop_server='', $pop_port='') {
if (!$pop_port) {
$pop_port = 110;
}