This repository was archived by the owner on Jun 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmail.php
More file actions
62 lines (48 loc) · 1.34 KB
/
mail.php
File metadata and controls
62 lines (48 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Copyright (c) Vincent Klaiber.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @see https://github.com/wordplate/mail
*/
/*
* Plugin Name: Mail
* Description: A custom SMTP credentials plugin for WordPress.
* Author: WordPlate
* Author URI: https://github.com/wordplate/wordplate
* Version: 7.3.0
* Plugin URI: https://github.com/wordplate/mail
*/
use PHPMailer\PHPMailer\PHPMailer;
function mail_credentials(PHPMailer $mail)
{
$mail->IsSMTP();
$mail->SMTPAutoTLS = false;
$mail->SMTPAuth = true;
$mail->SMTPSecure = $_ENV['MAIL_ENCRYPTION'] ?? 'tls';
$mail->Host = $_ENV['MAIL_HOST'];
$mail->Port = $_ENV['MAIL_PORT'] ?? 587;
$mail->Username = $_ENV['MAIL_USERNAME'];
$mail->Password = $_ENV['MAIL_PASSWORD'];
return $mail;
}
add_action('phpmailer_init', 'mail_credentials');
function mail_content_type()
{
return 'text/html';
}
add_filter('wp_mail_content_type', 'mail_content_type');
function mail_from_address()
{
return $_ENV['MAIL_FROM_ADDRESS'] ?? $_ENV['MAIL_USERNAME'];
}
add_filter('wp_mail_from', 'mail_from_address');
if (isset($_ENV['MAIL_FROM_NAME'])) {
function mail_from_name()
{
return $_ENV['MAIL_FROM_NAME'];
}
add_filter('wp_mail_from_name', 'mail_from_name');
}