我正在为客户开发一个项目,它从数据库中选择一封电子邮件,然后向该地址发送一封电子邮件。在运行CentOS 6的VPS服务器上一切正常,但是当迁移到共享主机时,程序将不再发送电子邮件。它将选择正确的地址,但不会发送任何消息,我已经安装了Pear Mail和Mail_mime。有什么想法吗?
此代码连接到服务器:
$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';
此代码选择收件人:
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
$addresses[] = $row['email'];
}
$recipients = implode(", ", $addresses);
希望你能帮助我!
答案 0 :(得分:0)
这是我的电子邮件发送代码
$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);
答案 1 :(得分:0)
好吧,我解决了。我用默认的邮件功能替换了梨邮件。