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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
<?php
// DO NOT CALL THIS CLASS DIRECTLY. CALL VIA: pb_backupbuddy_destination in bootstrap.php.
class pb_backupbuddy_destination_email { public static $destination_info = array( 'name' => 'Email', 'description' => 'Send files as email attachments. With most email servers attachments are typically <b>limited to about 10 MB</b> in size so only small backups typically can be sent this way.', ); // Default settings. Should be public static for auto-merging. public static $default_settings = array( 'type' => 'email', // MUST MATCH your destination slug. 'title' => '', // Required destination field. 'address' => '', ); /* send() * * Send one or more files. * * @param array $files Array of one or more files to send. * @return boolean True on success, else false. */ public static function send( $settings = array(), $files = array(), $send_id = '' ) { $email = $settings['address']; if ( pb_backupbuddy::$options['email_return'] != '' ) { $email_return = pb_backupbuddy::$options['email_return']; } else { $email_return = get_option('admin_email'); } pb_backupbuddy::status( 'details', 'Sending remote email.' ); $headers = 'From: BackupBuddy <' . $email_return . '>' . "\r\n"; $wp_mail_result = wp_mail( $email, 'BackupBuddy backup for ' . site_url(), 'BackupBuddy backup for ' . site_url(), $headers, $files ); pb_backupbuddy::status( 'details', 'Sent remote email.' ); if ( $wp_mail_result === true ) { // WP sent. Hopefully it makes it! return true; } else { // WP couldn't try to send. return false; } } // End send(). /* test() * * Sends a text email with ImportBuddy.php zipped up and attached to it. * * @param array $settings Destination settings. * @return bool|string True on success, string error message on failure. */ public static function test( $settings ) { $email = $settings['address']; pb_backupbuddy::status( 'details', 'Testing email destination. Sending ImportBuddy.php.' ); pb_backupbuddy::anti_directory_browsing( backupbuddy_core::getTempDirectory(), $die = false ); $importbuddy_temp = backupbuddy_core::getTempDirectory() . 'importbuddy_' . pb_backupbuddy::random_string( 10 ) . '.php.tmp'; // Full path & filename to temporary importbuddy backupbuddy_core::importbuddy( $importbuddy_temp ); // Create temporary importbuddy. $files = array( $importbuddy_temp ); if ( pb_backupbuddy::$options['email_return'] != '' ) { $email_return = pb_backupbuddy::$options['email_return']; } else { $email_return = get_option('admin_email'); } $headers = 'From: BackupBuddy <' . $email_return . '>' . "\r\n"; $wp_mail_result = wp_mail( $email, 'BackupBuddy Test', 'BackupBuddy destination test for ' . site_url(), $headers, $files ); pb_backupbuddy::status( 'details', 'Sent test email.' ); @unlink( $importbuddy_temp ); if ( $wp_mail_result === true ) { // WP sent. Hopefully it makes it! return true; } else { // WP couldn't try to send. echo 'WordPress was unable to attempt to send email. Check your WordPress & server settings.'; return false; } } // End test(). } // End class.
|