PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Intermittent Email with Mail Mime

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail
View previous topic :: View next topic  
Author Message
lordleiter



Joined: 14 Feb 2008
Posts: 4
Location: Souther California

PostPosted: Thu Feb 14, 2008 9:33 pm    Post subject: Intermittent Email with Mail Mime Reply with quote

I've set up a PHP page that sends emails via the PEAR Mail Mime class. I used the basic example from the documentation. For the most part, the script works fine, but for some reason some email just never arrive. The script runs through all the way, so there are no errors. It's just that some emails never arrive at their destination. I can't find a common thread as to what emails work and which don't. Anyone else have this issue? Better yet, anyone else already solve this issue?
Back to top
View user's profile Send private message AIM Address
mark



Joined: 07 Jan 2007
Posts: 1051

PostPosted: Thu Feb 14, 2008 11:19 pm    Post subject: Reply with quote

If it only some mails don't make it through, it doesn't seem to be a general issue with Mail_mime. It's more likely that some servers reject your email, maybe because they identify your emails as spam or because your host is blacklisted.

An easy check for the latter reason would be to use the 'smtp' option of the Mail class together with your credentials for your personal email account. You could send the emails again with this option, and see whether the emails make their way now.
Back to top
View user's profile Send private message
lordleiter



Joined: 14 Feb 2008
Posts: 4
Location: Souther California

PostPosted: Fri Feb 15, 2008 12:02 am    Post subject: How to debug Reply with quote

Your suggestion sounds logical. The problem I'm having now is trying to set up the authentication. Do you happen to know how to throw out the errors when "debug" is set to true?
Back to top
View user's profile Send private message AIM Address
lordleiter



Joined: 14 Feb 2008
Posts: 4
Location: Souther California

PostPosted: Fri Feb 15, 2008 12:09 am    Post subject: Here's what I have to start Reply with quote

[code]<?php
echo '1... ';

ini_set('include_path', $_SERVER['DOCUMENT_ROOT'].'/pear');

$text = "Test message";

include('Mail.php');
include('Mail/mime.php');

$crlf = "\n";
$hdrs = array(
'To' => "Fname Lname <you@domain.com>",
'From' => "Joe Schmoe <me@domain.com>",
'Subject' => "Test Email"
);

echo '2... ';

$mime = new Mail_mime($crlf);

$mime->setTXTBody($text);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$params = Array('host' => 'localhost', 'port' => 25, 'debug' => true);

echo '3... ';

$mail =& Mail::factory('smtp', $params);

echo '4... ';

$mail->send('you@domain.com', $hdrs, $body);

echo '5... ';

?> [/code]

With this page, the result will echo out up to "4... ", but not "5... ".
Back to top
View user's profile Send private message AIM Address
mark



Joined: 07 Jan 2007
Posts: 1051

PostPosted: Fri Feb 15, 2008 11:27 am    Post subject: Reply with quote

Maybe you haven't installed the Net_SMTP and Net_Socket packages?

You might want to add the following lines at the beginning of your script to get more reasonable error messages for debugging:
Code:

error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'PEAR.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);


You should also check the results:
Code:

$res = $mail->send('you@domain.com', $hdrs, $body);
if (PEAR::isError($res)) {
    die($res->getMessage() . ', ' . $res->getDebugInfo());
}
Back to top
View user's profile Send private message
lordleiter



Joined: 14 Feb 2008
Posts: 4
Location: Souther California

PostPosted: Fri Feb 15, 2008 9:16 pm    Post subject: BAM! Reply with quote

Thank you so much. The missing PEAR packages was indeed the key.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Mail All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software