* @return array
* List of error messages.
*/
- protected static function sendReminderEmail($tokenRow, $schedule, $toContactID) {
+ protected static function sendReminderEmail($tokenRow, $schedule, $toContactID): array {
$toEmail = CRM_Contact_BAO_Contact::getPrimaryEmail($toContactID, TRUE);
if (!$toEmail) {
return ["email_missing" => "Couldn't find recipient's email address."];
'entity_id' => $schedule->id,
];
- if (!$body_html || $tokenRow->context['contact']['preferred_mail_format'] == 'Text' ||
- $tokenRow->context['contact']['preferred_mail_format'] == 'Both'
+ if (!$body_html || $tokenRow->context['contact']['preferred_mail_format'] === 'Text' ||
+ $tokenRow->context['contact']['preferred_mail_format'] === 'Both'
) {
// render the & entities in text mode, so that the links work
$mailParams['text'] = str_replace('&', '&', $body_text);
}
- if ($body_html && ($tokenRow->context['contact']['preferred_mail_format'] == 'HTML' ||
- $tokenRow->context['contact']['preferred_mail_format'] == 'Both'
+ if ($body_html && ($tokenRow->context['contact']['preferred_mail_format'] === 'HTML' ||
+ $tokenRow->context['contact']['preferred_mail_format'] === 'Both'
)
) {
$mailParams['html'] = $body_html;
}
$result = CRM_Utils_Mail::send($mailParams);
- if (!$result || is_a($result, 'PEAR_Error')) {
+ if (!$result) {
return ['email_fail' => 'Failed to send message'];
}
* @return bool
* TRUE if a mail was sent, else FALSE.
*/
- public static function send(&$params) {
+ public static function send(array &$params): bool {
$defaultReturnPath = CRM_Core_BAO_MailSettings::defaultReturnPath();
$includeMessageId = CRM_Core_BAO_MailSettings::includeMessageId();
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
}
if (!empty($attachments)) {
- foreach ($attachments as $fileID => $attach) {
+ foreach ($attachments as $attach) {
$msg->addAttachment(
$attach['fullPath'],
$attach['mime_type'],
$headers = $msg->headers($headers);
$to = [$params['toEmail']];
- $result = NULL;
$mailer = \Civi::service('pear_mail');
// CRM-3795, CRM-7355, CRM-7557, CRM-9058, CRM-9887, CRM-12883, CRM-19173 and others ...