mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-24 15:48:55 +01:00
fix bug regarding certain russian filenames when forwarding/compose as new, as AddStringAttachment is using basename to make sure only a filename will be used for the namepart; some fixes backported from phpmailer5.2.1
This commit is contained in:
parent
73f26d2432
commit
22a5fbb4b3
@ -15,7 +15,7 @@ require_once(EGW_API_INC.'/class.phpmailer.inc.php');
|
|||||||
/**
|
/**
|
||||||
* Log mails to log file specified in $GLOBALS['egw_info']['server']['log_mail']
|
* Log mails to log file specified in $GLOBALS['egw_info']['server']['log_mail']
|
||||||
* or regular error_log for true (can be set either in DB or header.inc.php).
|
* or regular error_log for true (can be set either in DB or header.inc.php).
|
||||||
*
|
*
|
||||||
* This class does NOT use anything EGroupware specific, it acts like PHPMail, but logs.
|
* This class does NOT use anything EGroupware specific, it acts like PHPMail, but logs.
|
||||||
*/
|
*/
|
||||||
class egw_mailer extends PHPMailer
|
class egw_mailer extends PHPMailer
|
||||||
@ -26,9 +26,9 @@ class egw_mailer extends PHPMailer
|
|||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct(true); // throw exceptions instead of echoing errors
|
parent::__construct(true); // throw exceptions instead of echoing errors
|
||||||
|
|
||||||
// setting EGroupware specific path for PHPMailer lang files
|
// setting EGroupware specific path for PHPMailer lang files
|
||||||
list($lang,$nation) = explode('-',$GLOBALS['egw_info']['user']['preferences']['common']['lang']);
|
if (!empty($GLOBALS['egw_info']['user']['preferences']['common']['lang'])) list($lang,$nation) = explode('-',$GLOBALS['egw_info']['user']['preferences']['common']['lang']);
|
||||||
$lang_path = EGW_SERVER_ROOT.'/phpgwapi/lang/';
|
$lang_path = EGW_SERVER_ROOT.'/phpgwapi/lang/';
|
||||||
if ($nation && file_exists($lang_path."phpmailer.lang-$nation.php")) // atm. only for pt-br => br
|
if ($nation && file_exists($lang_path."phpmailer.lang-$nation.php")) // atm. only for pt-br => br
|
||||||
{
|
{
|
||||||
@ -43,10 +43,10 @@ class egw_mailer extends PHPMailer
|
|||||||
/**
|
/**
|
||||||
* Log mails to log file specified in $GLOBALS['egw_info']['server']['log_mail']
|
* Log mails to log file specified in $GLOBALS['egw_info']['server']['log_mail']
|
||||||
* or regular error_log for true (can be set either in DB or header.inc.php).
|
* or regular error_log for true (can be set either in DB or header.inc.php).
|
||||||
*
|
*
|
||||||
* We can NOT supply this method as callback to phpMailer, as phpMailer only accepts
|
* We can NOT supply this method as callback to phpMailer, as phpMailer only accepts
|
||||||
* functions (not methods) and from a function we can NOT access $this->ErrorInfo.
|
* functions (not methods) and from a function we can NOT access $this->ErrorInfo.
|
||||||
*
|
*
|
||||||
* @param boolean $isSent
|
* @param boolean $isSent
|
||||||
* @param string $to
|
* @param string $to
|
||||||
* @param string $cc
|
* @param string $cc
|
||||||
@ -89,21 +89,21 @@ class egw_mailer extends PHPMailer
|
|||||||
* Initiates a connection to an SMTP server.
|
* Initiates a connection to an SMTP server.
|
||||||
* Returns false if the operation failed.
|
* Returns false if the operation failed.
|
||||||
*
|
*
|
||||||
* Overwriting this method from phpmailer, to make sure we set SMTPSecure to ssl or tls if the standardports for ssl or tls
|
* Overwriting this method from phpmailer, to make sure we set SMTPSecure to ssl or tls if the standardports for ssl or tls
|
||||||
* are configured for the given profile
|
* are configured for the given profile
|
||||||
*
|
*
|
||||||
* @uses SMTP
|
* @uses SMTP
|
||||||
* @access public
|
* @access public
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function SmtpConnect()
|
public function SmtpConnect()
|
||||||
{
|
{
|
||||||
$port = $this->Port;
|
$port = $this->Port;
|
||||||
$hosts = explode(';',$this->Host);
|
$hosts = explode(';',$this->Host);
|
||||||
foreach ($hosts as $k => &$host)
|
foreach ($hosts as $k => &$host)
|
||||||
{
|
{
|
||||||
$host = trim($host); // make sure there is no whitespace leading or trailling the host string
|
$host = trim($host); // make sure there is no whitespace leading or trailling the host string
|
||||||
if (in_array($port,array(465,587)) && strpos($host,'://')===false)
|
if (in_array($port,array(465,587)) && strpos($host,'://')===false)
|
||||||
{
|
{
|
||||||
//$host = ($port==587?'tls://':'ssl://').trim($host);
|
//$host = ($port==587?'tls://':'ssl://').trim($host);
|
||||||
$this->SMTPSecure = ($port==587?'tls':'ssl');
|
$this->SMTPSecure = ($port==587?'tls':'ssl');
|
||||||
@ -176,4 +176,33 @@ class egw_mailer extends PHPMailer
|
|||||||
|
|
||||||
return parent::AddBCC($address, $name);
|
return parent::AddBCC($address, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a string or binary attachment (non-filesystem) to the list.
|
||||||
|
* This method can be used to attach ascii or binary data,
|
||||||
|
* such as a BLOB record from a database.
|
||||||
|
* @param string $string String attachment data.
|
||||||
|
* @param string $filename Name of the attachment. We assume that this is NOT a path
|
||||||
|
* @param string $encoding File encoding (see $Encoding).
|
||||||
|
* @param string $type File extension (MIME) type.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream')
|
||||||
|
{
|
||||||
|
// Append to $attachment array
|
||||||
|
//already encoded?
|
||||||
|
//TODO: maybe add an parameter to AddStringAttachment to avoid using the basename
|
||||||
|
$x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $filename, $matches);
|
||||||
|
$this->attachment[] = array(
|
||||||
|
0 => $string,
|
||||||
|
1 => $filename,
|
||||||
|
2 => ($x?basename($filename):$filename),
|
||||||
|
3 => $encoding,
|
||||||
|
4 => $type,
|
||||||
|
5 => true, // isStringAttachment
|
||||||
|
6 => 'attachment',
|
||||||
|
7 => 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ class PHPMailer {
|
|||||||
private $bcc = array();
|
private $bcc = array();
|
||||||
private $ReplyTo = array();
|
private $ReplyTo = array();
|
||||||
private $all_recipients = array();
|
private $all_recipients = array();
|
||||||
private $attachment = array();
|
protected $attachment = array(); //this way extended classes may use this variable
|
||||||
private $CustomHeader = array();
|
private $CustomHeader = array();
|
||||||
private $message_type = '';
|
private $message_type = '';
|
||||||
private $boundary = array();
|
private $boundary = array();
|
||||||
@ -1199,7 +1199,7 @@ class PHPMailer {
|
|||||||
$body = '';
|
$body = '';
|
||||||
|
|
||||||
if ($this->sign_key_file) {
|
if ($this->sign_key_file) {
|
||||||
$body .= $this->GetMailMIME();
|
$body .= $this->GetMailMIME()."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->SetWordWrap();
|
$this->SetWordWrap();
|
||||||
@ -1245,7 +1245,7 @@ class PHPMailer {
|
|||||||
$body .= $this->EncodeString($this->Body, $this->Encoding);
|
$body .= $this->EncodeString($this->Body, $this->Encoding);
|
||||||
$body .= $this->LE.$this->LE;
|
$body .= $this->LE.$this->LE;
|
||||||
// Create the extended body for an attached text/calendar
|
// Create the extended body for an attached text/calendar
|
||||||
$body .= $this->GetBoundary($this->boundary[2], '', $this->attachment[0][4], '') . $this->LE;
|
$body .= $this->GetBoundary($this->boundary[2], '', $this->attachment[0][4], '') . $this->LE;
|
||||||
$body .= $this->EncodeString($this->attachment[0][0], $this->attachment[0][3]);
|
$body .= $this->EncodeString($this->attachment[0][0], $this->attachment[0][3]);
|
||||||
$body .= $this->LE.$this->LE;
|
$body .= $this->LE.$this->LE;
|
||||||
$body .= $this->EndBoundary($this->boundary[2]);
|
$body .= $this->EndBoundary($this->boundary[2]);
|
||||||
@ -1262,8 +1262,8 @@ class PHPMailer {
|
|||||||
$signed = tempnam("", "signed");
|
$signed = tempnam("", "signed");
|
||||||
if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
|
if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) {
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
@unlink($signed);
|
|
||||||
$body = file_get_contents($signed);
|
$body = file_get_contents($signed);
|
||||||
|
@unlink($signed);
|
||||||
} else {
|
} else {
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
@unlink($signed);
|
@unlink($signed);
|
||||||
@ -1491,16 +1491,16 @@ class PHPMailer {
|
|||||||
* @access private
|
* @access private
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function &EncodeFile($path, $encoding = 'base64')
|
private function &EncodeFile($path, $encoding = 'base64')
|
||||||
{
|
{
|
||||||
if (function_exists('get_magic_quotes'))
|
if (function_exists('get_magic_quotes'))
|
||||||
{
|
{
|
||||||
function get_magic_quotes()
|
function get_magic_quotes()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PHP_VERSION < 6)
|
if (PHP_VERSION < 6)
|
||||||
{
|
{
|
||||||
if (function_exists('get_magic_quotes_runtime') && ($magic_quotes = get_magic_quotes_runtime())) set_magic_quotes_runtime(0);
|
if (function_exists('get_magic_quotes_runtime') && ($magic_quotes = get_magic_quotes_runtime())) set_magic_quotes_runtime(0);
|
||||||
}
|
}
|
||||||
@ -1510,13 +1510,13 @@ class PHPMailer {
|
|||||||
throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
|
throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE);
|
||||||
}
|
}
|
||||||
$file_buffer = $this->EncodeString($file_buffer, $encoding);
|
$file_buffer = $this->EncodeString($file_buffer, $encoding);
|
||||||
if (PHP_VERSION < 6)
|
if (PHP_VERSION < 6)
|
||||||
{
|
{
|
||||||
if ($magic_quotes) set_magic_quotes_runtime($magic_quotes);
|
if ($magic_quotes) set_magic_quotes_runtime($magic_quotes);
|
||||||
}
|
}
|
||||||
return $file_buffer;
|
return $file_buffer;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
if (PHP_VERSION < 6)
|
if (PHP_VERSION < 6)
|
||||||
{
|
{
|
||||||
if ($magic_quotes) set_magic_quotes_runtime($magic_quotes);
|
if ($magic_quotes) set_magic_quotes_runtime($magic_quotes);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user