1 | <?php |
---|
2 | |
---|
3 | require 'wp-load.php'; |
---|
4 | |
---|
5 | require_once ABSPATH . WPINC . '/class-phpmailer.php'; |
---|
6 | |
---|
7 | class PrintPHPMailer extends PHPMailer { |
---|
8 | /** |
---|
9 | * Override send() so mail isn't actually sent. |
---|
10 | */ |
---|
11 | function send() { |
---|
12 | try { |
---|
13 | if ( ! $this->preSend() ) { |
---|
14 | return false; |
---|
15 | } |
---|
16 | |
---|
17 | echo $this->getSentMIMEMessage(); |
---|
18 | |
---|
19 | return true; |
---|
20 | } catch ( phpmailerException $e ) { |
---|
21 | return false; |
---|
22 | } |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | $phpmailer = new PrintPHPMailer( true ); |
---|
27 | |
---|
28 | add_action( 'phpmailer_init', function( $mailer ) { |
---|
29 | $mailer->AltBody = 'Wörld'; |
---|
30 | $mailer->Encoding = 'quoted-printable'; |
---|
31 | } ); |
---|
32 | |
---|
33 | wp_mail( |
---|
34 | get_site_option( 'admin_email' ), |
---|
35 | 'Hello', |
---|
36 | '<p><strong>Wörld</strong></p>', |
---|
37 | array( |
---|
38 | 'Content-Type: text/html', |
---|
39 | sprintf( 'From: %s', get_site_option( 'admin_email' ) ) |
---|
40 | ) |
---|
41 | ); |
---|