Jump to content
The Uniform Server Community
Sign in to follow this  
devo

send an email from the db_backup.php file

Recommended Posts

I have successfully set up automatic database backups and have also set up and successfully tested sending an email thanks to the great instructions found here: http://wiki.uniformserver.com/index.php/5....Database_Backup.

 

I have added a section to the bottom of the db_backup.php file that will email a copy of the 7z file that was just created. However the db_backup.php file does not know how to use the php mail function (which I have configured in msmtprc.ini file.) I can use the mail function within any page the exists in the www directory.

 

(As an alternative I was going to add a Header redirection to the bottom of the db_backup.php file and send it to another php file in the www directory that would send the email. However since the db_backup.php file outputs text to the screen and its log file, the header redirection will not work.)

 

Does anyone have any suggestions on how I can get the db_backup.php file to recognize the php mail function?

Share this post


Link to post
Share on other sites

To use the PHP mail function in CLI scripts the path to msmtp requires adding to the PHP CLI configuration file as follows:

 

Note: Depending on where you installed Uniform Server your paths will be different

 

Open file: C:\UniServer\usr\local\php\php.ini

Locate this line: sendmail_path = "C:/UniServer/msmtp/msmtp.exe --file=C:/UniServer/msmtp/msmtprc.ini -t"

 

Copy the above line and paste it at the end of file: C:\UniServer\usr\local\php\cli.ini

 

Note: Paths in file C:\UniServer\usr\local\php\php.ini are not updated when servers are moved for example to another folder or USB stick. If you want portability the run_location_tracker() function requires modification as follows:

 

Edit file: C:\UniServer\unicon\main\includes\functions.php

 

Locate these lines:

file_search_replace(USF_PHP_INI,$s_str,US_BASE_F); // Update PHP ini

file_search_replace(USF_PHP_INI_PROD,$s_str,US_BASE_F); // Update PHP production ini

file_search_replace(USF_PHP_INI_DEV,$s_str,US_BASE_F); // Update PHP development ini

 

To the end of the above lines add the following line:

file_search_replace(USF_PHP_INI_CLI,$s_str,US_BASE_F); // Update PHP cli ini

 

All the best

Ric ;)

Share this post


Link to post
Share on other sites

Thank you Ric! You are a star!

 

And going the extra mile with the functions.php tip.

 

You have made my day. Thank you very much.

 

Devo

 

(A slight correction for anyone else learning from this thread: cli.ini filename is actually php-cli.ini)

Share this post


Link to post
Share on other sites

Thanks for the update and correction.

Please note added the above to UniServer 7.1.12-Orion

 

All the best

Ric ;)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...