简体   繁体   English

Pear无法在共享主机上发送电子邮件

[英]Pear Can't send email on Shared Hosting

I was working on a project for a client, it selects an email from a database and then sends an email to that address. 我正在为一个客户开发项目,它从数据库中选择一封电子邮件,然后将电子邮件发送到该地址。 Everything worked fine on my VPS server running CentOS 6, but when migrating to their shared hosting the program will no longer send the email. 在运行CentOS 6的VPS服务器上,一切正常,但在迁移到它们的共享主机时,该程序将不再发送电子邮件。 It will select the correct addresses, but no message will be sent, I've already installed Pear Mail and Mail_mime. 它将选择正确的地址,但不会发送任何消息,因为我已经安装了Pear Mail和Mail_mime。 Any thoughts? 有什么想法吗?

This code connects to the server: 此代码连接到服务器:

$headers['From']    = 'mail@openmailbox.org'; 
$headers['To']      = 'mail@openmailbox.org'; 
$headers['Subject'] = $asunto;




$params['host'] = 'smtp.openmailbox.org';
$params['port'] = '25';
$params['auth'] = 'PLAIN';
$params['username'] = 'mail@openmailbox.org';
$params['password'] = 'password';

This code selects the recipients: 此代码选择收件人:

$result = mysql_query($query);

while($row = mysql_fetch_array($result))
{
$addresses[] = $row['email'];
}
$recipients = implode(", ", $addresses);

Hope you can help me! 希望你能帮我!

Here, this is my email sending code 这是我的电子邮件发送代码

$mail =& Mail::factory('smtp', $params);



    $mime = new Mail_mime($crlf);

    $mime->setTXTBody($text);
    $mime->setHTMLBody($html);

    $body = $mime->get();
    $headers = $mime->headers($headers);


    $mail->send($recipients, $headers, $body);

Well, I solved it. 好吧,我解决了。 I replaced pear mail with the default mail function. 我用默认的邮件功能替换了梨邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM