Make WordPress Core

Ticket #28039: 28039-test.php

File 28039-test.php, 751 bytes (added by mdawaffe, 11 years ago)

php 28039-test.php

Line 
1<?php
2
3require 'wp-load.php';
4
5require_once ABSPATH . WPINC . '/class-phpmailer.php';
6
7class 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
28add_action( 'phpmailer_init', function( $mailer ) {
29        $mailer->AltBody = 'Wörld';
30        $mailer->Encoding = 'quoted-printable';
31} );
32
33wp_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);