/    Sign up×
Community /Pin to ProfileBookmark

Anyone use Mail_Queue? Need help

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

[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 = ‘[email protected]’;
$from_name = ‘My Name’;
$recipient = ‘[email protected]’;
$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>”);
?>
[/code]

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.

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.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Pacopag spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...