From: <pdo...@us...> - 2022-04-13 21:38:29
|
Revision: 14945 http://sourceforge.net/p/squirrelmail/code/14945 Author: pdontthink Date: 2022-04-13 21:38:27 +0000 (Wed, 13 Apr 2022) Log Message: ----------- Add proper RFC 3461 DSN functionality (previously we relied only on the Return-Receipt-To header) Modified Paths: -------------- branches/SM-1_4-STABLE/squirrelmail/class/deliver/Deliver_SMTP.class.php Modified: branches/SM-1_4-STABLE/squirrelmail/class/deliver/Deliver_SMTP.class.php =================================================================== --- branches/SM-1_4-STABLE/squirrelmail/class/deliver/Deliver_SMTP.class.php 2022-04-13 20:08:39 UTC (rev 14944) +++ branches/SM-1_4-STABLE/squirrelmail/class/deliver/Deliver_SMTP.class.php 2022-04-13 21:38:27 UTC (rev 14945) @@ -340,7 +340,17 @@ 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 ($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); @@ -351,7 +361,17 @@ 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 ($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); @@ -362,7 +382,17 @@ 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 ($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); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |