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 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器