wp-db-backup icon indicating copy to clipboard operation
wp-db-backup copied to clipboard

Attached email backup file as noname

Open injiniero opened this issue 5 years ago • 4 comments

After wp 5.5 update the attached backup file sent by email arrives with noname

injiniero avatar Aug 28 '20 06:08 injiniero

Same problem here. Backup worked, updated WP to 5.5, e-mail attachements are broken.

Previous: X-Mailer: PHPMailer 5.2.27 Current: X-Mailer: PHPMailer 6.1.6

Previous: Content-Type: multipart/mixed; boundary="b1_56d2a9d3c58c5306a23e188ad7e0b57b"

Current: Content-Type: multipart/mixed; charset=

Guess: Missing "boundary" in the e-mail body. Thunderbird doesn't show any attachemt, K9-Mail/Android shows an error.

hgdrn avatar Sep 03 '20 18:09 hgdrn

I've found the problem: PHPMailer has moved to another directory thus the "require_once" fails and the old method is used for sending the e-mail (which is buggy). The needed changes are two additional lines of code and one change to an existing line of code. Details tomorrow, if anybody is interrested in it.

hgdrn avatar Sep 10 '20 19:09 hgdrn

First: PHPMailer has moved to a different location. In function send_mail() one has to include it

		if ( !is_object( $phpmailer ) || ( strtolower(get_class( $phpmailer )) != 'phpmailer' ) ) {
			// <fix for wp5.5>
			if ( file_exists( ABSPATH . WPINC . '/PHPMailer/PHPMailer.php' ) )
				require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
			// </fix for wp5.5>
			if ( file_exists( ABSPATH . WPINC . '/class-phpmailer.php' ) )
				require_once ABSPATH . WPINC . '/class-phpmailer.php';

Second: strtolower(get_class( $phpmailer )) provides "phpmailer\phpmailer\phpmailer" thus the if-statement fails

		// try to use phpmailer directly (WP 2.2+)
		// <fix for wp5.5>
		// if ( is_object( $phpmailer ) && ( strtolower(get_class( $phpmailer )) == 'phpmailer' ) ) {
		if ( is_object( $phpmailer )
			&& (
		    	( strtolower(get_class( $phpmailer )) == 'phpmailer' ) 
		    	||
			( strtolower(get_class( $phpmailer )) == 'phpmailer\phpmailer\phpmailer' )
		 	)
		) {	
		// </fix for wp5.5>

Plugin works for me again with these changes. Just trying to provide a pull request now, please stand by.

hgdrn avatar Sep 11 '20 08:09 hgdrn

Thank you, hgdrn. It works!

injiniero avatar Dec 25 '20 08:12 injiniero