+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2016
*/
class CRM_Utils_Mail {
* @return Mail
*/
public static function createMailer() {
- $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
- 'mailing_backend'
- );
+ $mailingInfo = Civi::settings()->get('mailing_backend');
if ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB ||
(defined('CIVICRM_MAILER_SPOOL') && CIVICRM_MAILER_SPOOL)
else {
$mailer = Mail::factory($driver, $params);
}
- CRM_Utils_Hook::alterMail($mailer, $driver, $params);
+ CRM_Utils_Hook::alterMailer($mailer, $driver, $params);
return $mailer;
}
* TRUE if a mail was sent, else FALSE.
*/
public static function send(&$params) {
- $returnPath = CRM_Core_BAO_MailSettings::defaultReturnPath();
+ $defaultReturnPath = CRM_Core_BAO_MailSettings::defaultReturnPath();
$includeMessageId = CRM_Core_BAO_MailSettings::includeMessageId();
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
$from = CRM_Utils_Array::value('from', $params);
- if (!$returnPath) {
- $returnPath = self::pluckEmailFromHeader($from);
+ if (!$defaultReturnPath) {
+ $defaultReturnPath = self::pluckEmailFromHeader($from);
}
- $params['returnPath'] = $returnPath;
// first call the mail alter hook
CRM_Utils_Hook::alterMailParams($params);
$headers['Content-Type'] = $htmlMessage ? 'multipart/mixed; charset=utf-8' : 'text/plain; charset=utf-8';
$headers['Content-Disposition'] = 'inline';
$headers['Content-Transfer-Encoding'] = '8bit';
- $headers['Return-Path'] = CRM_Utils_Array::value('returnPath', $params);
+ $headers['Return-Path'] = CRM_Utils_Array::value('returnPath', $params, $defaultReturnPath);
// CRM-11295: Omit reply-to headers if empty; this avoids issues with overzealous mailservers
- $replyTo = CRM_Utils_Array::value('replyTo', $params, $from);
+ $replyTo = CRM_Utils_Array::value('replyTo', $params, CRM_Utils_Array::value('from', $params));
if (!empty($replyTo)) {
$headers['Reply-To'] = $replyTo;
$headers['Auto-Submitted'] = "Auto-Generated";
}
- //make sure we has to have space, CRM-6977
+ // make sure we has to have space, CRM-6977
foreach (array('From', 'To', 'Cc', 'Bcc', 'Reply-To', 'Return-Path') as $fld) {
if (isset($headers[$fld])) {
$headers[$fld] = str_replace('"<', '" <', $headers[$fld]);
// Mail_smtp and Mail_sendmail mailers require Bcc anc Cc emails
// be included in both $to and $headers['Cc', 'Bcc']
if (get_class($mailer) != "Mail_mail") {
- //get emails from headers, since these are
- //combination of name and email addresses.
+ // get emails from headers, since these are
+ // combination of name and email addresses.
if (!empty($headers['Cc'])) {
$to[] = CRM_Utils_Array::value('Cc', $headers);
}
* TRUE if valid outBound email configuration found, false otherwise.
*/
public static function validOutBoundMail() {
- $mailingInfo = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
- 'mailing_backend'
- );
+ $mailingInfo = Civi::settings()->get('mailing_backend');
if ($mailingInfo['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_MAIL) {
return TRUE;
}
* and if so does the needful and return the formatted name
*
* This code has been copied and adapted from ezc/Mail/src/tools.php
+ *
+ * @param string $name
+ *
+ * @return string
*/
public static function formatRFC2822Name($name) {
$name = trim($name);
public static function appendPDF($fileName, $html, $format = NULL) {
$pdf_filename = CRM_Core_Config::singleton()->templateCompileDir . CRM_Utils_File::makeFileName($fileName);
- //FIXME : CRM-7894
- //xmlns attribute is required in XHTML but it is invalid in HTML,
- //Also the namespace "xmlns=http://www.w3.org/1999/xhtml" is default,
- //and will be added to the <html> tag even if you do not include it.
+ // FIXME : CRM-7894
+ // xmlns attribute is required in XHTML but it is invalid in HTML,
+ // Also the namespace "xmlns=http://www.w3.org/1999/xhtml" is default,
+ // and will be added to the <html> tag even if you do not include it.
$html = preg_replace('/(<html)(.+?xmlns=["\'].[^\s]+["\'])(.+)?(>)/', '\1\3\4', $html);
file_put_contents($pdf_filename, CRM_Utils_PDF_Utils::html2pdf($html,