gpt4 book ai didi

php - 使用 PEAR 的 Mail_Queue 时遇到问题

转载 作者:行者123 更新时间:2023-11-30 23:34:22 24 4
gpt4 key购买 nike

我正在尝试实现 PEAR 的 Mail_Queue 包来为 Web 应用程序排队一些电子邮件。我使用了 http://pear.php.net/manual/en/package.mail.mail-queue.mail-queue.tutorial.php 上的文档编写一个小的测试脚本。

我的问题是数据库没有更新,也没有产生错误。

编辑

// mail_queue db options
$db_options['type'] = 'mdb2';
$db_options['dsn'] = DSN;
$db_options['mail_table'] = 'mail_queue';

// mail_queue sending options
$mail_options['driver'] = 'smtp';
$mail_options['host'] = 'smtp.gmail.com';
$mail_options['port'] = 25;
$mail_options['localhost'] = $host;
$mail_options['auth'] = true;
$mail_options['user'] = MAILUSER;
$mail_options['pass'] = MAILPASS;

require "Queue.php";

$mail_queue =& new Mail_Queue($db_options,$mail_options);

$from = 'someone@domain.ca';
$to = 'martin@starmedia.ca';
$message = 'This is a test';

$headers = array('From' => $from,
'To' => $to,
'Subject' => 'Someone has sent you an email!');

$mime =& new Mail_mime();
$mime->setTXTBody($message);
$body = $mime->get();

$headers = $mime->headers($headers,true);
print $mail_queue->put($from,$to,$headers,$body);

这会产生错误 Mail Queue Error: Cannot connect to database 。但是我检查了所有的连接信息,它是正确的。此外,添加 if (PEAR::isError($mail)) die($mail->getMessage()); 不会产生任何错误!

最佳答案

好的,我的邮件队列文件终于可以工作了。以下是我为使其正常运行所采取的步骤:

<强>1。启用错误消息

为了启用错误处理,我添加了这个片段:

function handle_pear_error($e) {
die($e->getMessage() . ' ' . print_r($e->getUserInfo(), true));
}
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handle_pear_error');

添加此内容后,我重新加载了页面,但出现以下错误:

Call to undefined function: MDB2_Driver_mysql::_isNewLinkSet()

<强>2。更新 MDB2 的 MySQL 驱动程序

我搜索了该错误,发现它通常是由于没有最新的 MDB2 库或其 MySQL 驱动程序造成的。

所以我更新了两者并且它工作正常!

关于php - 使用 PEAR 的 Mail_Queue 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8882563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com