I'm trying to send emails via php with on Elastix. When I run the php as a ssh it works but when I try to do it on Web (PHP) I doesn't send anything. This is my code:
#!/usr/bin/php -q
<?php
echo shell_exec('whoami');
shell_exec("sudo sendEmail -f j.example@example.com -t example@example.com -u Subject -m Message-s example.com.mx -o tls=yes -xu j.user@example.com.mx -xp password");
?>
I think is something about permissions because when I run it on my command line the output is:
root
and the email is send. But in when I try to open the file via Web i doesn't send anything, The output is next:
Asteriks
So I tried to give Asteriks root permissions, but it doesn't work :(. In another try to do it I download the PHPMailer library but i doesn't send the email. I try to do it on Windows with Xampp and it works and is the same version of PHP (5.1.6).
This is my PHPMailer code:
<?PHP
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'example.com';
$mail->SMTPAuth = true;
$mail->Username = 'example@example.com';
$mail->Password = 'password';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->From = 'example@example.com';
$mail->FromName = 'Name';
$mail->addAddress('example@example.com');
$mail->WordWrap = 50;
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
It works on Windows but it doesn't on Elastix Any help?