I have had a similar problem in the past with phpMySQLAutoBackup and I was unable to solve it at the time and gave up on it. Solving the email problem with my own site got me thinking about phpMySQLAutoBackup again.
I have hacked phpmysqlautobackup_extras.php to make use of phpMailer to send SMTP emails. This has solved my own problem with emails not being received and also gives some potential improvements, e.g. the ability to change the sender and the capability to cc the email to another account.
You need to edit the xmail function in files/phpmysqlautobackup_extras.php and delete all the code in that function and insert the phpmailer code shown below:
Code: Select all
function xmail ($to_emailaddress,$from_emailaddress, $subject, $content, $file_name, $backup_type)
// Modification to use phpMailer (http://phpmailer.codeworxtech.com/) to send SMTP emails
$phpmailer_hosthame = ""; // e.g. "yourdomain.com"
$phpmailer_host = ""; // e.g. "mail.yourdomain.com"
$phpmailer_port = "25"; // Most likely "25"
$phpmailer_username = ""; // e.g. "email@example.com"
$phpmailer_password = ""; // Your password
$phpmailer_sender = ""; // e.g. "firstname.lastname@example.org"
$phpmailer_from = $phpmailer_sender;
$phpmailer_fromname = ""; // Your name
$phpmailer_to = ""; // e.g. "email@example.com"
$phpmailer_toname = ""; // Your name
$phpmailer_cc = ""; // e.g. "firstname.lastname@example.org" - Leave blank if you don't want to cc the email.
$phpmailer_ccname = ""; // Your name
$phpmailer_subject = "phpMySQLAutoBackup: " . $file_name;
"<b>BACKUP Successful...</b> <br /><br />\n\n"
. "Please see attached for your zipped Backup file; $backup_type <br />\n"
. "If this is the first backup then you should test it restores correctly to a test server. <br /><br />\n\n"
. "phpMySQLAutoBackup is developed by <a href='http://www.dwalker.co.uk/'>www.dwalker.co.uk</a> <br /><br />\n\n"
. "Have a good day now you have a backup of your MySQL db ;-) <br /><br />\n\n"
. "Please consider making a donation at: <br />\n"
. "<a href='http://www.dwalker.co.uk/make_a_donation.php'>www.dwalker.co.uk/make_a_donation.php</a> <br />\n"
. "(any amount is gratefully received) <br />\n";
"BACKUP Successful... \n\n"
. "Please see attached for your zipped Backup file; $backup_type \n"
. "If this is the first backup then you should test it restores correctly to a test server. \n\n"
. "phpMySQLAutoBackup is developed by http://www.dwalker.co.uk/ \n\n"
. "Have a good day now you have a backup of your MySQL db ;-) \n\n"
. "Please consider making a donation at: \n"
. "http://www.dwalker.co.uk/make_a_donation.php \n"
. "(any amount is gratefully received) \n";
// Download phpMail from http://phpmailer.codeworxtech.com/ and upload these 3 files.
// These 3 files are all you need to upload unless you want to use a different language file.
// The 'require' statments below assume you create a phpmailer directory at the same level as you phpmysqlautobackup directory, e.g.
require( "../phpmailer/class.phpmailer.php" );
require( "../phpmailer/class.smtp.php" );
require( "../phpmailer/language/phpmailer.lang-en.php" );
$phpmailer = new PHPMailer();
$phpmailer -> IsSMTP();
$phpmailer -> HostName = $phpmailer_hosthame;
$phpmailer -> Host = $phpmailer_host;
$phpmailer -> Port = $phpmailer_port;
$phpmailer -> SMTPAuth = TRUE;
$phpmailer -> Username = $phpmailer_username;
$phpmailer -> Password = $phpmailer_password;
$phpmailer -> Sender = $phpmailer_sender;
$phpmailer -> From = $phpmailer_from;
$phpmailer -> FromName = $phpmailer_fromname;
$phpmailer -> AddAddress( $phpmailer_to, $phpmailer_toname );
if ( !empty( $phpmailer_cc ) )
$phpmailer -> AddCC( $phpmailer_cc, $phpmailer_ccname );
$phpmailer -> Subject = $phpmailer_subject;
$phpmailer -> Body = $phpmailer_htmlbody;
$phpmailer -> AltBody = $phpmailer_textbody;
$attach = $phpmailer -> AddStringAttachment( $content, $file_name, $encoding = "base64", $type = "application/octet-stream" );
$result = $phpmailer -> Send();
if ( !$result )
$err_msg = $phpmailer -> ErrorInfo;
echo "ERROR: $err_msg<br />\n";
You also need to download phpMailer from their website (http://phpmailer.codeworxtech.com/) and upload 3 files:
There are some comments in the code about where it expects to find these files, namely in a directory at the same 'level' as the phpmysqlautobackup directory. If you install phpMailer somewhere else you will need to change the code.
All the settings that phpMailer uses are in phpmysqlautobackup_extras.php and it ignores the email addresses set in run.php.
Note - although the email addresses set in run.php are not used by this hack you must still set them something (anything) as there is a check elsewhere in the code that will only send an email if they are set.
This hack could be integrated in a better way, i.e. all the settings moved into run.php and also a flag in run.php to indicate whether the existing xmail function should be used the send emails or a new phpmailer_xmail function instead. This would give users the ability to decide whether to download and install phpMailer.
I hope this is of use to someone!