set sender/return-path and from, if empty in identity, setting send/return-path from account, prefering smtp user-name and from from identity

This commit is contained in:
Ralf Becker 2014-11-25 11:32:25 +00:00
parent 0df2e9c23f
commit 2a0889bcf6
2 changed files with 10 additions and 8 deletions

View File

@ -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 {

View File

@ -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));
}