| 1 |
<?php |
| 2 |
|
| 3 |
// Files can easily get way 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 |
foreach ($backup_array as $type => $file) { |
| 14 |
$fullpath = $updraft_dir.$file; |
| 15 |
#if (file_exists($fullpath) && filesize($fullpath) > ... |
| 16 |
$any_sent = false; |
| 17 |
foreach (explode(',', UpdraftPlus_Options::get_updraft_option('updraft_email')) as $sendmail_addr) { |
| 18 |
$send_short = (strlen($sendmail_addr)>5) ? substr($sendmail_addr, 0, 5).'...' : $sendmail_addr; |
| 19 |
$updraftplus->log("$file: email to: $send_short"); |
| 20 |
|
| 21 |
$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'), $type).' '.__('Be wary; email backups may fail because of file size limitations on mail servers.','updraftplus'), null, array($fullpath)); |
| 22 |
if ($sent) $any_sent = true; |
| 23 |
} |
| 24 |
if ($any_sent) { |
| 25 |
$updraftplus->uploaded_file($file); |
| 26 |
} else { |
| 27 |
$updraftplus->log('Mails were not sent successfully'); |
| 28 |
$updraftplus->log(__('The attempt to send the backup via email failed (probably the backup was too large for this method)', 'updraftplus'), 'error'); |
| 29 |
} |
| 30 |
} |
| 31 |
return null; |
| 32 |
} |
| 33 |
|
| 34 |
public static function config_print() { |
| 35 |
?> |
| 36 |
<tr class="updraftplusmethod email"> |
| 37 |
<th><?php _e('Note:','updraftplus');?></th> |
| 38 |
<td><?php echo str_replace('>','>', str_replace('<','<',htmlspecialchars(__('The email address entered above will be used. If choosing "E-Mail", then <strong>be aware</strong> that mail servers tend to have size limits; typically around 10-20Mb; backups larger than any limits will not arrive. If you really need a large backup via email, then you could fund a new feature (to break the backup set into configurable-size pieces) - but the demand has not yet existed for such a feature.','updraftplus'))));?></td> |
| 39 |
</tr> |
| 40 |
<?php |
| 41 |
} |
| 42 |
|
| 43 |
public function delete($files) { |
| 44 |
} |
| 45 |
|
| 46 |
} |
| 47 |
|