我无法在Elastix上通过php发送电子邮件

琼·佩拉尔塔

我正在尝试在Elastix上通过php发送电子邮件。当我将php作为ssh运行时,它可以工作,但是当我尝试在Web(PHP)上运行时,我什么也没发送。这是我的代码:

#!/usr/bin/php -q  
<?php
    echo shell_exec('whoami');
    shell_exec("sudo sendEmail -f [email protected] -t [email protected] -u Subject -m Message-s example.com.mx -o tls=yes -xu [email protected] -xp password");
?>

我认为这与权限有关,因为在命令行上运行时,输出为:

然后电子邮件已发送。但是,当我尝试通过Web打开文件时,我什么也不发送,输出如下:

星号

因此,我尝试赋予Asteriks根权限,但它不起作用:(。在另一种尝试中,我下载了PHPMailer库,但没有发送电子邮件。我尝试在Windows上使用Xampp进行操作,并且它可以正常工作与PHP(5.1.6)的版本相同。

这是我的PHPMailer代码:

<?PHP
    $mail = new PHPMailer;

    $mail->isSMTP();                                   
    $mail->Host = 'example.com';
    $mail->SMTPAuth = true;           
    $mail->Username = '[email protected]';      
    $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 = '[email protected]';
    $mail->FromName = 'Name';
    $mail->addAddress('[email protected]'); 

    $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';
    }
?>

它可以在Windows上运行,但不能在Elastix上运行。有帮助吗?

琼·佩拉尔塔

因此,终于可以通过PHP发送电子邮件了。PHPMailer库无法在PHP 5.1.6上正常工作,因此,由于(最终)给我的错误是:

解析错误:语法错误,var / www / html /[...]/ class.phpmailer.php在行3040上出现意外T_FUNCTION

所以我碰巧将class.phpmailer.php的代码变成这样:

/**
     * Clear queued addresses of given kind.
     * @access protected
     * @param string $kind 'to', 'cc', or 'bcc'
     * @return void
     */
    protected function clearQueuedAddresses($kind)
    {
        //if (version_compare(PHP_VERSION, '5.3.0', '<')) {
            $RecipientsQueue = $this->RecipientsQueue;
            foreach ($RecipientsQueue as $address => $params) {
                if ($params[0] == $kind) {
                    unset($this->RecipientsQueue[$address]);
                }
            }
        //} else {
        //    $this->RecipientsQueue = array_filter(
        //        $this->RecipientsQueue,
        //        function ($params) use ($kind) {
        //            return $params[0] != $kind;
        //        });
        //}
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章