| 1 |
<?php |
| 2 |
|
| 3 |
// Files can easily get too big for this method |
| 4 |
|
| 5 |
class UpdraftPlus_BackupModule_email { |
| 6 |
|
| 7 |
public function backup($backup_array) { |
| 8 |
|
| 9 |
global $updraftplus, $updraftplus_backup; |
| 10 |
|
| 11 |
$updraft_dir = trailingslashit($updraftplus->backups_dir_location()); |
| 12 |
|
| 13 |
$email = $updraftplus->just_one_email(UpdraftPlus_Options::get_updraft_option('updraft_email'), true); |
| 14 |
|
| 15 |
if (!is_array($email)) $email = array($email); |
| 16 |
|
| 17 |
foreach ($backup_array as $type => $file) { |
| 18 |
|
| 19 |
$descrip_type = (preg_match('/^(.*)\d+$/', $type, $matches)) ? $matches[1] : $type; |
| 20 |
|
| 21 |
$fullpath = $updraft_dir.$file; |
| 22 |
#if (file_exists($fullpath) && filesize($fullpath) > ... |
| 23 |
$any_attempted = false; |
| 24 |
$any_sent = false; |
| 25 |
foreach ($email as $ind => $addr) { |
| 26 |
|
| 27 |
if (!apply_filters('updraftplus_email_wholebackup', true, $addr, $ind)) continue; |
| 28 |
|
| 29 |
foreach (explode(',', $addr) as $sendmail_addr) { |
| 30 |
|
| 31 |
$send_short = (strlen($sendmail_addr)>5) ? substr($sendmail_addr, 0, 5).'...' : $sendmail_addr; |
| 32 |
$updraftplus->log("$file: email to: $send_short"); |
| 33 |
$any_attempted = true; |
| 34 |
|
| 35 |
$sent = wp_mail(trim($sendmail_addr), __("WordPress Backup", 'updraftplus')." ".get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraftplus->backup_time), 'Y-m-d H:i'), sprintf(__("Backup is of: %s.",'updraftplus'), $descrip_type).' '.__('Be wary; email backups may fail because of file size limitations on mail servers.','updraftplus'), null, array($fullpath)); |
| 36 |
if ($sent) $any_sent = true; |
| 37 |
} |
| 38 |
} |
| 39 |
if ($any_sent) { |
| 40 |
$updraftplus->uploaded_file($file); |
| 41 |
} elseif ($any_attempted) { |
| 42 |
$updraftplus->log('Mails were not sent successfully'); |
| 43 |
$updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error'); |
| 44 |
} else { |
| 45 |
$updraftplus->log('No email addresses were configured to send to'); |
| 46 |
} |
| 47 |
} |
| 48 |
return null; |
| 49 |
} |
| 50 |
|
| 51 |
public function config_print() { |
| 52 |
?> |
| 53 |
<tr class="updraftplusmethod email"> |
| 54 |
<th><?php _e('Note:', 'updraftplus');?></th> |
| 55 |
<td><?php |
| 56 |
$used = apply_filters('updraftplus_email_whichaddresses', sprintf(__("Your site's admin email address (%s) will be used.", 'updraftplus'), get_bloginfo('admin_email')).' <a href="http://updraftplus.com/shop/reporting/">'.sprintf(__('For more options, use the "%s" add-on.', 'updraftplus'), __('Reporting', 'updraftplus')).'</a>'); |
| 57 |
echo str_replace('>','>', str_replace('<','<',htmlspecialchars($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'))));?> |
| 58 |
</td> |
| 59 |
</tr> |
| 60 |
<?php |
| 61 |
} |
| 62 |
|
| 63 |
public function delete($files) { |
| 64 |
return true; |
| 65 |
} |
| 66 |
|
| 67 |
} |
| 68 |
|