Hi. I just had my hosting company install PEAR::Mail_Queue for me. I tried running the following script, which seems to be the simplest online example I can find
At first, this kept spitting out errors about .php files not being found. I had to go through some of theme (e.g. Queue.php, mime.php...) and change all the "require once" lines so that they had absolute paths instead of relative ones.Code:<?php require_once "/home/user/php/Mail/Queue.php"; $container_options = array( 'type' => 'db', 'database' => 'mydbname', 'phptype' => 'mysql', 'username' => 'dbusername', 'password' => 'dbpassword', 'mail_table' => 'mail_queue', ); $mail_options = array( 'driver' => 'smtp', 'host' => 'mydomain.com', 'port' => 25, 'auth' => false, 'username' => '', 'password' => '', ); $mail_queue =& new Mail_Queue($container_options, $mail_options); $from = 'user@mydomain.com'; $from_name = 'My Name'; $recipient = 'somebody@gmail.com'; $recipient_name = 'Somebody'; $message = 'Test message'; $from_params = empty($from_name) ? '<'.$from.'>' : '"'.$from_name.'" <'.$from.'>'; $recipient_params = empty($recipient_name) ? '<'.$recipient.'>' : '"'.$recipient_name.'" <'.$recipient.'>'; $hdrs = array( 'From' => $from_params, 'To' => $recipient_params, 'Subject' => 'test message body', ); $mime =& new Mail_mime(); $mime->setTXTBody($message); $body = $mime->get(); $hdrs = $mime->headers($hdrs); // Put message to queue $mail_queue->put($from, $recipient, $hdrs, $body); // Also you could put this msg in more advanced mode $seconds_to_send = 3600; $delete_after_send = false; $id_user = 7; $mail_queue->put( $from, $recipient, $hdrs, $body, $seconds_to_send, $delete_after_send, $id_user ); $max_ammount_mails = 50; $mail_queue =& new Mail_Queue($container_options, $mail_options); $mail_queue->sendMailsInQueue($max_ammount_mails); echo("<p>Done</p>"); ?>
Anyway, the script gives no errors, but the mail is just not going through. Anyone know what may cause this to happen? Or maybe some very simple examples to test with?
Thanks.


Reply With Quote
Bookmarks