Working smtp for email

This commit is contained in:
osaajani 2020-04-16 07:50:30 +02:00
parent 379eaa2786
commit 48ef0c063e
8 changed files with 49 additions and 35 deletions

View file

@ -50,6 +50,8 @@ class Launcher extends AbstractDaemon
$this->start_sender_daemon();
$this->start_webhook_daemon();
$this->start_mailer_daemon();
$phones = $this->internal_phone->get_all();
$this->start_phones_daemons($phones);
@ -74,6 +76,25 @@ class Launcher extends AbstractDaemon
$pid = null;
exec('php ' . PWD . '/console.php controllers/internals/Console.php sender > /dev/null 2>&1 &');
}
/**
* Function to start mailer daemon.
*/
public function start_mailer_daemon()
{
$name = 'RaspiSMS Daemon Mailer';
$pid_file = PWD_PID . '/' . $name . '.pid';
if (file_exists($pid_file))
{
return false;
}
//Create a new daemon for sender
$pid = null;
exec('php ' . PWD . '/console.php controllers/internals/Console.php mailer > /dev/null 2>&1 &');
}
/**
* Function to start webhook daemon.

View file

@ -55,7 +55,7 @@ class Mailer extends AbstractDaemon
$message = null;
$error_code = null;
$success = msg_receive($this->mailer_queue, QUEUE_TYPE_MAIL, $msgtype, $maxsize, $message, true, MSG_IPC_NOWAIT, $error_code); //MSG_IPC_NOWAIT == dont wait if no message found
$success = msg_receive($this->mailer_queue, QUEUE_TYPE_EMAIL, $msgtype, $maxsize, $message, true, MSG_IPC_NOWAIT, $error_code); //MSG_IPC_NOWAIT == dont wait if no message found
if (!$success && MSG_ENOMSG !== $error_code)
{
$this->logger->critical('Error for mailer queue reading, error code : ' . $error_code);
@ -90,7 +90,7 @@ class Mailer extends AbstractDaemon
public function on_start()
{
//Set last message at to construct time
$this->mailer_queue = msg_get_queue(QUEUE_ID_MAIL);
$this->mailer_queue = msg_get_queue(QUEUE_ID_EMAIL);
$this->logger->info('Starting Mailer daemon with pid ' . getmypid());
}
@ -98,7 +98,7 @@ class Mailer extends AbstractDaemon
public function on_stop()
{
//Delete queue on daemon close
$this->logger->info('Closing queue : ' . QUEUE_ID_MAIL);
$this->logger->info('Closing queue : ' . QUEUE_ID_EMAIL);
msg_remove_queue($this->mailer_queue);
$this->logger->info('Stopping Mailer daemon with pid ' . getmypid());