dplece1882 2012-01-16 15:54
浏览 31
已采纳

麻烦使用PEAR的Mail_Queue

I'm trying to implement PEAR's Mail_Queue package to queue some emails for a web application. I've used the documentation at http://pear.php.net/manual/en/package.mail.mail-queue.mail-queue.tutorial.php to write a small test script.

My problem is that the database is not being updated, and it's not producing errors.

EDIT

// 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);

This produces the error Mail Queue Error: Cannot connect to database . However I checked all of the connection information and it's correct. Also, adding if (PEAR::isError($mail)) die($mail->getMessage()); produces no errors!

  • 写回答

1条回答 默认 最新

  • douxuan4556 2012-01-20 17:54
    关注

    OK, I finally have my mail queue file working. Here are the steps I took to get it to function:

    1. Enable error messages

    To enable error handling, I added this snippet:

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

    Once I added this, I reloaded the page and I was getting the following error:

    Call to undefined function: MDB2_Driver_mysql::_isNewLinkSet()
    

    2. Update MDB2's MySQL driver

    I searched that error and found that it's usually a result of either not having an up-to-date MDB2 library or its MySQL driver.

    So I updated both and it's working!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数