Make WordPress Core

Ticket #49661: logphpmailer.php

File logphpmailer.php, 796 bytes (added by arena, 5 years ago)

logphpmailer.php

Line 
1<?php
2if ( !class_exists( 'LogPhpMailer' ) )
3{
4/*
5        Plugin Name: LogPhpMailer
6        Description: create eml
7        Author: me
8        Version: 0.0.7
9*/
10class LogPhpMailer
11{
12        function __construct() 
13        {
14                add_action( 'phpmailer_init', array( __CLASS__, 'phpmailer_init' ) );
15        }
16
17        public static function phpmailer_init( $mail ) 
18        {
19                $mail->preSend();
20                $message = $mail->getSentMIMEMessage();
21
22                $upload_dir  = wp_upload_dir();
23                $dir = trailingslashit( $upload_dir['basedir'] ) . 'phpmailer/';
24                if ( !is_dir( $dir ) ) mkdir( $dir );
25
26                $f = $dir . uniqid( rand() );
27
28                $fname = $f . '.eml';
29                file_put_contents( $fname, $message );
30/*
31                $f_dbt = $f . '_dbt.eml';
32                $calls = debug_backtrace();
33                file_put_contents( $f_dbt, print_r( $calls, true ) );
34*/
35        }
36}
37new LogPhpMailer();
38}