PluginProbe
UpdraftPlus: WP Backup & Migration Plugin / 1.13.6
UpdraftPlus: WP Backup & Migration Plugin v1.13.6
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.13.6, at methods/email.php

90 lines 3.6 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($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 foreach ($email as $ind => $addr) {
36
37 if (!apply_filters('updraftplus_email_wholebackup', true, $addr, $ind, $type)) continue;
38
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 }
51 if ($any_sent) {
52 if (isset($toobig_hash)) {
53 $updraftplus->log_removewarning('toobigforemail_'.$toobig_hash);
54 // Don't leave it still set for the next archive
55 unset($toobig_hash);
56 }
57 $updraftplus->uploaded_file($file);
58 } elseif ($any_attempted) {
59 $updraftplus->log('Mails were not sent successfully');
60 $updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error');
61 } else {
62 $updraftplus->log('No email addresses were configured to send to');
63 }
64 }
65 return null;
66 }
67
68 public function config_print() {
69 ?>
70 <tr class="updraftplusmethod email">
71 <th><?php _e('Note:', 'updraftplus');?></th>
72 <td><?php
73
74 $used = apply_filters('updraftplus_email_whichaddresses',
75 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>').
76 ' <a href="'.apply_filters("updraftplus_com_link", "https://updraftplus.com/shop/reporting/").'">'.sprintf(__('For more options, use the "%s" add-on.', 'updraftplus'), __('Reporting', 'updraftplus')).'</a>'
77 );
78
79 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');
80 ?>
81 </td>
82 </tr>
83 <?php
84 }
85
86 public function delete($files, $data = null, $sizeinfo = array()) {
87 return true;
88 }
89 }
90