Commit 0628b7df by Manzar Hussain

php mailer

parent 56fcf5f9
INTRODUCTION
------------
Uses the PHPMailer library to send emails via SMTP.
For a full description of the module, visit the project page:
http://drupal.org/project/phpmailer_smtp
To submit bug reports and feature suggestions, or to track changes:
http://drupal.org/project/issues/phpmailer_smtp
REQUIREMENTS
------------
* Access to an SMTP server
* The Mail System module. This allows you specify different backends for
formatting and sending e-mails
http://www.drupal.org/project/mailsystem
* PHPMailer library 6 - installed via composer
Optional:
* To connect to an SMTP server using SSL/TLS, your PHP installation needs to
have SSL support.
* Mime Mail module to format HTML emails
http://www.drupal.org/project/mimemail
* Swift Mailer module to format HTML emails
https://www.drupal.org/project/swiftmailer
INSTALLATION
------------
composer require drupal/phpmailer_smtp
CONFIGURATION
-------------
* Configure user permissions at Administer >> User management >> Access
control >> PHPMailer SMTP module.
Only users with the "administer phpmailer smtp settings" permission are
allowed to access the module configuration page.
* Configure your SMTP server settings at Administer >> Configuration >>
PHPMailer SMTP.
* Configure your Mail System settings at Administer >> Configuration >>
Mail System.
Select "PHPMailer SMTP" as "Sender" under "Default Mail System" and "Module-
Specific Configuration" as required.
EXAMPLES
--------
Port 465 is now encouraged: https://tools.ietf.org/html/rfc8314
* Using Google Mail or Google Apps as SMTP server
To send e-mails with Google Mail use the following settings:
SMTP server: smtp.gmail.com
SMTP port: 465
Secure protocol: SSL
Username: your_google_mail_name@gmail.com
or: your_username@your_google_apps_domain.com
Password: your_google_mail_password
In Advanced SMTP settings:
Enable 'Always set "Reply-To" address' checkbox.
Also note the sending limits for Google Mail accounts:
http://mail.google.com/support/bin/answer.py?hl=en&answer=22839
General instructions for Google Mail accounts:
http://mail.google.com/support/bin/answer.py?answer=13287
* Errors when trying to send a test email
If you see the following error messages when trying to send a test email from
the settings page:
SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
SMTP Error: Could not connect to SMTP host.
it means the mail server can not be reached, usually because your hosting
provider is blocking the port by a firewall. The solution is to ask your
provider to allow outgoing connections to your mail server.
* Debug settings
PHPMailer SMTP supports rerouting all e-mails for debugging purposes, to
prevent you from accidentally sending out e-mails to real users from a
development site. To enable this feature, add the following lines to the end
of your settings.php (usually located in sites/default):
$conf['system.maintenance']['phpmailer_smtp_debug_email']
= 'your_debug_email@yoursite.com';
This will change the recipient of all e-mails to the configured address.
{
"name": "drupal/phpmailer_smtp",
"type": "drupal-module",
"description": "Uses the PHPMailer library to send emails via SMTP.",
"homepage": "https://drupal.org/project/phpmailer_smtp",
"license": "GPL-2.0+",
"require": {
"phpmailer/phpmailer": "^6.1.8"
},
"authors": [
{
"name": "Ian McLean (imclean)",
"homepage": "http://drupal.org/u/imclean"
}
],
"support": {
"issues": "https://www.drupal.org/project/issues/phpmailer_smtp",
"source": "https://git.drupalcode.org/project/phpmailer_smtp"
},
"keywords": ["drupal", "phpmailer", "smtp", "email", "mail", "mailsystem", "mail system"]
}
smtp_host: 'localhost'
smtp_hostbackup: ''
smtp_port: 25
smtp_protocol: ''
smtp_username: ''
smtp_password: ''
smtp_hide_password: 0
smtp_fromname: ''
smtp_always_replyto: 0
smtp_keepalive: 0
smtp_debug: 0
smtp_debug_log: 0
phpmailer_smtp_test: ''
smtp_ssl_verify_peer: 1
smtp_ssl_verify_peer_name: 1
smtp_ssl_allow_self_signed: 0
smtp_envelope_sender_option: 'default'
smtp_envelope_sender: ''
smtp_ehlo_host: ''
smtp_timeout: 30
phpmailer_smtp.settings:
type: config_object
label: 'PHPMailer SMTP Settings'
mapping:
smtp_host:
type: string
label: 'SMTP host'
smtp_hostbackup:
type: string
label: 'SMTP host backup'
smtp_port:
type: integer
label: 'SMTP port'
smtp_protocol:
type: string
label: 'SMTP protocol'
smtp_username:
type: string
label: 'SMTP username'
smtp_password:
type: string
label: 'SMTP password'
smtp_hide_password:
type: boolean
label: 'Hide password'
smtp_fromname:
type: string
label: 'From name'
smtp_always_replyto:
type: boolean
label: 'Always set Reply-To'
smtp_keepalive:
type: boolean
label: 'Keep alive'
smtp_debug:
type: integer
label: 'Debug level'
smtp_debug_log:
type: boolean
label: 'Debug log'
phpmailer_smtp_test:
type: string
label: 'SMTP test address'
smtp_ssl_verify_peer:
type: boolean
label: 'Verify peer'
smtp_ssl_verify_peer_name:
type: boolean
label: 'Verify peer name'
smtp_ssl_allow_self_signed:
type: boolean
label: 'Allow self-sigend'
smtp_envelope_sender_option:
type: string
label: 'Envelope sender option'
smtp_envelope_sender:
type: email
label: 'Envelope sender'
smtp_ehlo_host:
type: string
label: 'EHLO host'
smtp_timeout:
type: integer
label: 'SMTP timeout'
{
"require": {
"phpmailer/phpmailer": {
"version": "v6.1.8",
"url": "https://github.com/PHPMailer/PHPMailer/archive/v6.1.8.zip"
}
}
}
name: PHPMailer SMTP
description: Uses the PHPMailer library to send emails via SMTP.
type: module
package: Mail
configure: phpmailer_smtp.settings
core_version_requirement: ^8.8 || ^9
# Information added by Drupal.org packaging script on 2020-11-23
version: '2.0.2'
project: 'phpmailer_smtp'
datestamp: 1606107103
<?php
/**
* @file
* PHPMailer SMTP installation functions.
*/
use PHPMailer\PHPMailer\PHPMailer;
/**
* Implements hook_requirements().
*/
function phpmailer_smtp_requirements($phase) {
$requirements = [];
if (class_exists('PHPMailer\PHPMailer\PHPMailer')) {
$mail = new PHPMailer();
}
if (empty($mail)) {
$requirements['phpmailer_smtp'] = [
'title' => (string) t('PHPMailer library'),
'value' => (string) t('Missing'),
'severity' => REQUIREMENT_ERROR,
'description' => (string) t("Please install the PHPMailer library by executing 'composer update' in your site's root directory."),
];
}
else {
$required_version = '6.1.8';
$installed_version = $mail::VERSION;
$requirements['phpmailer_smtp'] = [
'title' => (string) t('PHPMailer library'),
'value' => $installed_version,
];
if (!version_compare($installed_version, $required_version, '>=')) {
$requirements['phpmailer_smtp']['severity'] = REQUIREMENT_ERROR;
$requirements['phpmailer_smtp']['description'] = (string) t("PHPMailer library @version or higher is required. Please install a newer version by executing 'composer update' in your site's root directory.", [
'@version' => $required_version,
]);
}
else {
$requirements['phpmailer_smtp']['severity'] = REQUIREMENT_OK;
}
}
return $requirements;
}
/**
* Add SMTP timeout setting.
*/
function phpmailer_smtp_update_8001() {
\Drupal::configFactory()->getEditable('phpmailer_smtp.settings')
->set('smtp_timeout', 30)
->save(TRUE);
}
phpmailer_smtp.settings:
title: 'PHPMailer SMTP'
route_name: phpmailer_smtp.settings
parent: system.admin_config_system
description: "Configure the PHPMailer SMTP module."
<?php
/**
* @file
* Uses the PHPMailer library to send emails via SMTP.
*/
use Drupal\Component\Utility\Html;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function phpmailer_smtp_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.phpmailer_smtp':
$text = file_get_contents(__DIR__ . '/README.txt');
return '<pre>' . Html::escape($text) . '</pre>';
default:
}
}
administer phpmailer smtp settings:
title: 'Administer PHPMailer SMTP settings'
restrict access: TRUE
phpmailer_smtp.settings:
path: '/admin/config/system/phpmailer-smtp'
defaults:
_form: '\Drupal\phpmailer_smtp\Form\SettingsForm'
_title: 'Configure the PHPMailer SMTP module'
requirements:
_permission: 'administer phpmailer smtp settings'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment