我正在尝试实现 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());
不会产生错误!