Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Solved] Send Email via Script

Featured Replies

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

  • Community Expert

You want the "notify" command:

 

  • Author

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

 

Br,

Johannes

  • Community Expert
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.

  • Author

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

  • Community Expert
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:

 

  • Author

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

  • Community Expert
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.

  • Author

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

  • Author

Maybe, if too many workarounds are needed to get sendmail working I could go with a full blown vmware with debian (apache, php, exim or sendmail).

  • Author

Hi,

 

I was able to solve my problem with the script.

 

1) moved from mysql to mysqli commands

2) using phpmailer to send directly from PHP via Gmail

 

Br,

Johannes

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.