| Server IP : 157.230.181.24 / Your IP : 216.73.217.11 Web Server : Apache/2.4.58 (Ubuntu) System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64 User : ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/vhosts/maxons/public/modules/swiftmailer/ |
Upload File : |
<?php
/**
* @file
* This is the primary module file.
*/
use Drupal\Core\Render\Markup;
include_once __DIR__ . '/includes/helpers/utilities.inc';
// Define permissions.
define('SWIFTMAILER_ADMINISTER', 'swiftmailer_administer');
// Define message formats.
define('SWIFTMAILER_FORMAT_PLAIN', 'text/plain');
define('SWIFTMAILER_FORMAT_HTML', 'text/html');
// Define transport types.
define('SWIFTMAILER_TRANSPORT_SMTP', 'smtp');
define('SWIFTMAILER_TRANSPORT_SENDMAIL', 'sendmail');
define('SWIFTMAILER_TRANSPORT_NATIVE', 'native');
define('SWIFTMAILER_TRANSPORT_SPOOL', 'spool');
// Define header types.
define('SWIFTMAILER_HEADER_TEXT', 'text');
define('SWIFTMAILER_HEADER_PARAMETERIZED', 'parameterized');
define('SWIFTMAILER_HEADER_MAILBOX', 'mailbox');
define('SWIFTMAILER_HEADER_DATE', 'date');
define('SWIFTMAILER_HEADER_ID', 'ID');
define('SWIFTMAILER_HEADER_PATH', 'path');
// Define system variables defaults.
define('SWIFTMAILER_VARIABLE_RESPECT_FORMAT_DEFAULT', FALSE);
define('SWIFTMAILER_VARIABLE_CONVERT_MODE_DEFAULT', FALSE);
define('SWIFTMAILER_VARIABLE_PATH_DEFAULT', '');
define('SWIFTMAILER_VARIABLE_FORMAT_DEFAULT', 'text/plain');
define('SWIFTMAILER_VARIABLE_CHARACTER_SET_DEFAULT', 'UTF-8');
/**
* Implements hook_mail().
*/
function swiftmailer_mail($key, &$message) {
$user = \Drupal::currentUser();
$message['headers']['Content-Type'] = SWIFTMAILER_FORMAT_HTML;
$text[] = '<h3>' . t('Dear @user,', array('@user' => $user->getDisplayName())) . '</h3>';
$text[] = '<p>' . t('This e-mail has been sent from @site by the Swift Mailer module. The module has been successfully configured.', array('@site' => \Drupal::config('system.site')->get('name'))) . '</p>';
$text[] = t('Kind regards') . '<br /><br />';
$text[] = t('The Swift Mailer module');
$message['subject'] = t('Swift Mailer has been successfully configured!');
$message['body'] = array_map(function ($text) { return Markup::create($text); }, $text);
}
/**
* Implements hook_theme().
*/
function swiftmailer_theme($existing, $type, $theme, $path) {
return array(
'swiftmailer' => array(
'variables' => array(
'message' => array(),
),
'mail theme' => TRUE,
),
);
}
/**
* Implements hook_theme_suggestions_HOOK() for swiftmailer.
*/
function swiftmailer_theme_suggestions_swiftmailer(array $variables) {
$suggestions = [];
$suggestions[] = 'swiftmailer';
$suggestions[] = 'swiftmailer__' . $variables['message']['module'];
$suggestions[] = 'swiftmailer__' . $variables['message']['module'] . '__' . $variables['message']['key'];
return $suggestions;
}
/**
* Prepares variables for swiftmailer templates.
*
* Default template: swiftmailer.html.twig.
*
* @param array $variables
* An associative array containing:
* - message: An associative array containing the message array.
* - body: The processed body.
*/
function template_preprocess_swiftmailer(&$variables) {
$variables['subject'] = $variables['message']['subject'];
$variables['body'] = $variables['message']['body'];
}