[Solved] Send Email via Script


Recommended Posts

Dear all,

 

On my old Webserver I have a visualisation of my solar-system, based on PHP and MySQL. In addition to that I am running a PHP Script which sends me an email if a temperature value decreases below a threshold.

On this server I also had Exim as Mail-Relay configured.

 

Now I want to port everything to UnRaid.

 

Therefore I Installed the MySQL Docker and the Apache Docker.

So far the Website is up and running, but the Script for sending out the email is not working (/usr/sbin/sendmail: not found)

 

How could I get this resolved with UnRaid?

 

Br,

Johannes

 

 

 

Edited by ebnerjoh
Link to comment
14 minutes ago, ebnerjoh said:

Can I run this within a PHP-File within a Docker?

 

Br,

Johannes

Sorry. I see what you are trying to do now. You can't run commands on the host from a docker. Maybe you could get the docker to write a file to a folder on the host and use inotifywait on the host to trigger an email when it sees the file.

 

Possibly you just need different docker that includes sendmail. Or you could docker exec into bash in the docker and install sendmail there. Any change you make to a docker like this will not persist if the docker is reinstalled.

 

Maybe someone else will have a better idea.

Link to comment

So I could run my PHP Script within the Docker, doing the SQL Check and SQL Update. 

 

But instead of sending an Email I could try to write a file into the docker.

 

Outside the docker I am monitoring the file and if there (either with cron or inotify) sending out the notification?

 

Br,

Johannes

Link to comment
34 minutes ago, ebnerjoh said:

So I could run my PHP Script within the Docker, doing the SQL Check and SQL Update. 

 

But instead of sending an Email I could try to write a file into the docker.

 

Outside the docker I am monitoring the file and if there (either with cron or inotify) sending out the notification?

 

Br,

Johannes

Something like that. Of course, you would need to write the file to a folder that was in a volume mapping. I will leave the details up to you to figure out.

 

Or install sendmail in the docker. Here is how to get to a command line inside the container:

 

Link to comment

I have also installed the LetsEncrypt-Docker. This docker seems to have sendmail installed.

 

I uploaded the script to the docker, but when executing the script I am getting the following error:

 

PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /config/www/email/check_temp_boiler.php:61
Stack trace:
#0 {main}
  thrown in /config/www/email/check_temp_boiler.php on line 61

From my basic knowledge I would say that this docker is not able to use the php function "mysql_connect". Correct?

 

Br,

Johannes

Link to comment
2 minutes ago, ebnerjoh said:

I have also installed the LetsEncrypt-Docker. This docker seems to have sendmail installed.

 

I uploaded the script to the docker, but when executing the script I am getting the following error:

 


PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /config/www/email/check_temp_boiler.php:61
Stack trace:
#0 {main}
  thrown in /config/www/email/check_temp_boiler.php on line 61

From my basic knowledge I would say that this docker is not able to use the php function "mysql_connect". Correct?

 

Br,

Johannes

I don't use any of this, but a quick google says mysql_connect is deprecated.

Link to comment

Thanks, 

 

this was a big help but I need to look in detail to it.

 

Last stupid question regarding sendmail.

Do I need to configure (mailserver, username, password,...) sendmail within the docker or do I have to do it via the mail command in order to send an email via gmail?

 

Br,

Johannes

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.