From 2a0889bcf6320b3d6813127f3eca169c2f5dd864 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 25 Nov 2014 11:32:25 +0000 Subject: [PATCH] set sender/return-path and from, if empty in identity, setting send/return-path from account, prefering smtp user-name and from from identity --- mail/inc/class.mail_compose.inc.php | 4 ++-- phpgwapi/inc/class.egw_mailer.inc.php | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 654d1b0022..d26e258e3a 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -2532,11 +2532,11 @@ class mail_compose //error_log("Folder:".count(array($this->sessionData['folder']))."To:".count((array)$this->sessionData['to'])."CC:". count((array)$this->sessionData['cc']) ."bcc:".count((array)$this->sessionData['bcc'])); if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { try { - $mail->Send(); + $mail->send(); } catch(Exception $e) { _egw_log_exception($e); - $this->errorInfo = $e->getMessage().($e->detail ? ': '.$e->detail : ''); + $this->errorInfo = $e->getMessage(); return false; } } else { diff --git a/phpgwapi/inc/class.egw_mailer.inc.php b/phpgwapi/inc/class.egw_mailer.inc.php index 090ff3dce7..82ee0b65a6 100644 --- a/phpgwapi/inc/class.egw_mailer.inc.php +++ b/phpgwapi/inc/class.egw_mailer.inc.php @@ -89,22 +89,24 @@ class egw_mailer extends Horde_Mime_Mail { $this->account = emailadmin_account::get_default(true); // true = need an SMTP (not just IMAP) account } - // use smpt-username as sender, if available, but only if it is a full email address + $identity = emailadmin_account::read_identity($this->account->ident_id, true, null, $this->account); + + // use smpt-username as sender/return-path, if available, but only if it is a full email address $sender = $this->account->acc_smtp_username && strpos($this->account->acc_smtp_username, '@') !== false ? - $this->account->acc_smtp_username : $this->account->ident_email; - $name = $this->account->ident_realname ? $this->account->ident_realname : $sender; - $this->setFrom($sender, $name); + $this->account->acc_smtp_username : $identity['ident_email']; + $this->addHeader('Return-Path', '<'.$sender.'>', true); + + $this->setFrom($identity['ident_email'], $identity['ident_realname']); } /** - * Set From and Return-Path header + * Set From header * * @param string $address * @param string $personal ='' */ public function setFrom($address, $personal='') { - $this->addHeader('Return-Path', '<'.$address.'>', true); $this->addHeader('From', self::add_personal($address, $personal)); }