PluginProbe
UpdraftPlus: WP Backup & Migration Plugin / 1.16.5
UpdraftPlus: WP Backup & Migration Plugin v1.16.5
1.26.7 1.26.6 1.26.5 1.26.4 1.26.3 1.9.19 1.9.25 1.9.26 1.9.30 1.9.31 1.9.32 1.9.4 1.9.40 1.9.41 1.9.42 1.9.43 1.9.44 1.9.45 1.9.46 1.9.5 1.9.50 1.9.51 1.9.60 1.9.62 1.9.63 All 371 releases
updraftplus / methods / email.php

email.php in UpdraftPlus: WP Backup & Migration Plugin 1.16.5, at methods/email.php

111 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('UPDRAFTPLUS_DIR')) die('No direct access allowed.');
4
5 // Files can easily get too big for this method
6
7 if (!class_exists('UpdraftPlus_BackupModule')) require_once(UPDRAFTPLUS_DIR.'/methods/backup-module.php');
8
9 class UpdraftPlus_BackupModule_email extends UpdraftPlus_BackupModule {
10
11 public function backup($backup_array) {
12
13 global $updraftplus, $updraftplus_backup;
14
15 $updraft_dir = trailingslashit($updraftplus->backups_dir_location());
16
17 $email = $updraftplus->just_one_email(UpdraftPlus_Options::get_updraft_option('updraft_email'), true);
18
19 if (!is_array($email)) $email = array_filter(array($email));
20
21 foreach ($backup_array as $type => $file) {
22
23 $descrip_type = preg_match('/^(.*)\d+$/', $type, $matches) ? $matches[1] : $type;
24
25 $fullpath = $updraft_dir.$file;
26
27 if (file_exists($fullpath) && filesize($fullpath) > UPDRAFTPLUS_WARN_EMAIL_SIZE) {
28 $size_in_mb_of_big_file = round(filesize($fullpath)/1048576, 1);
29 $toobig_hash = md5($file);
30 $updraftplus->log($file.': '.sprintf(__('This backup archive is %s MB in size - the attempt to send this via email is likely to fail (few email servers allow attachments of this size). If so, you should switch to using a different remote storage method.', 'updraftplus'), $size_in_mb_of_big_file), 'warning', 'toobigforemail_'.$toobig_hash);
31 }
32
33 $any_attempted = false;
34 $any_sent = false;
35 $any_skip = false;
36 foreach ($email as $ind => $addr) {
37
38 if (apply_filters('updraftplus_email_backup', true, $addr, $ind, $type)) {
39 foreach (explode(',', $addr) as $sendmail_addr) {
40
41 $send_short = (strlen($sendmail_addr)>5) ? substr($sendmail_addr, 0, 5).'...' : $sendmail_addr;
42 $updraftplus->log("$file: email to: $send_short");
43 $any_attempted = true;
44
45 $subject = __("WordPress Backup", 'updraftplus').': '.get_bloginfo('name').' (UpdraftPlus '.$updraftplus->version.') '.get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraftplus->backup_time), 'Y-m-d H:i');
46
47 $sent = wp_mail(trim($sendmail_addr), $subject, sprintf(__("Backup is of: %s.", 'updraftplus'), site_url().' ('.$descrip_type.')'), null, array($fullpath));
48 if ($sent) $any_sent = true;
49 }
50 } else {
51 $log_message = apply_filters('updraftplus_email_backup_skip_log_message', '', $addr, $ind, $descrip_type);
52 if (!empty($log_message)) {
53 $updraftplus->log($log_message);
54 }
55 $any_skip = true;
56 }
57 }
58 if ($any_sent) {
59 if (isset($toobig_hash)) {
60 $updraftplus->log_remove_warning('toobigforemail_'.$toobig_hash);
61 // Don't leave it still set for the next archive
62 unset($toobig_hash);
63 }
64 $updraftplus->uploaded_file($file);
65 } elseif ($any_attempted) {
66 $updraftplus->log('Mails were not sent successfully');
67 $updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error');
68 } elseif ($any_skip) {
69 $updraftplus->log('No email addresses were configured to send email to '.$descrip_type);
70 } else {
71 $updraftplus->log('No email addresses were configured to send to');
72 }
73 }
74 return null;
75 }
76
77 /**
78 * Acts as a WordPress options filter
79 *
80 * @param Array $options - An array of options
81 *
82 * @return Array - the returned array can either be the set of updated settings or a WordPress error array
83 */
84 public function options_filter($options) {
85 global $updraftplus;
86 return $updraftplus->just_one_email($options);
87 }
88
89 public function config_print() {
90 ?>
91 <tr class="updraftplusmethod email">
92 <th><?php _e('Note:', 'updraftplus');?></th>
93 <td><?php
94
95 $used = apply_filters('updraftplus_email_whichaddresses',
96 sprintf(__("Your site's admin email address (%s) will be used.", 'updraftplus'), get_bloginfo('admin_email').' - <a href="'.esc_attr(admin_url('options-general.php')).'">'.__("configure it here", 'updraftplus').'</a>').
97 ' <a href="'.apply_filters("updraftplus_com_link", "https://updraftplus.com/shop/reporting/").'" target="_blank">'.sprintf(__('For more options, use the "%s" add-on.', 'updraftplus'), __('Reporting', 'updraftplus')).'</a>'
98 );
99
100 echo $used.' '.sprintf(__('Be aware that mail servers tend to have size limits; typically around %s MB; backups larger than any limits will likely not arrive.', 'updraftplus'), '10-20');
101 ?>
102 </td>
103 </tr>
104 <?php
105 }
106
107 public function delete($files, $data = null, $sizeinfo = array()) {
108 return true;
109 }
110 }
111