-
Notifications
You must be signed in to change notification settings - Fork 0
/
set-email-return-path.php
59 lines (53 loc) · 1.38 KB
/
set-email-return-path.php
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
<?php
/**
* Plugin Name: Set Email Return-Path
* Description: Sets the Return-Path header of outgoing emails to the from email address. This helps solve issues when emails are sent from your hosts domain or IP address, and makes it look like your emails are spam.
* Version: 1.0.0
* License: GPLv3+
* Requires at least: 5.0
* Requires PHP: 7.0
* Author: James Hunt
* Author URI: https://www.thetwopercent.co.uk
**/
// Prohibit direct script loading.
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
// Load.
add_action( 'plugins_loaded', array( 'Set_Email_Return_Path', 'init' ), 1 );
/**
* Set Email Return Path
*
* @since 1.0.0
*/
class Set_Email_Return_Path {
/**
* Instance of the class
*
* @static
* @access protected
* @var object
*/
protected static $instance;
/**
* Instantiates the class.
*
* @return object $instance
*/
public static function init() {
is_null( self::$instance ) && self::$instance = new self();
return self::$instance;
}
/**
* Add to PHP mailer.
*/
public function __construct() {
add_action( 'phpmailer_init', array( $this, 'set_from' ) );
}
/**
* Change the sender.
*
* @param array $phpmailer PHP Mailer options.
*/
public function set_from( $phpmailer ) {
$phpmailer->Sender = $phpmailer->From; //phpcs:ignore
}
}