| View previous topic :: View next topic |
| Author |
Message |
lordleiter
Joined: 14 Feb 2008 Posts: 4 Location: Souther California
|
Posted: Thu Feb 14, 2008 9:33 pm Post subject: Intermittent Email with Mail Mime |
|
|
| 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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Thu Feb 14, 2008 11:19 pm Post subject: |
|
|
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 |
|
 |
lordleiter
Joined: 14 Feb 2008 Posts: 4 Location: Souther California
|
Posted: Fri Feb 15, 2008 12:02 am Post subject: How to debug |
|
|
| 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 |
|
 |
lordleiter
Joined: 14 Feb 2008 Posts: 4 Location: Souther California
|
Posted: Fri Feb 15, 2008 12:09 am Post subject: Here's what I have to start |
|
|
[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 |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Fri Feb 15, 2008 11:27 am Post subject: |
|
|
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 |
|
 |
lordleiter
Joined: 14 Feb 2008 Posts: 4 Location: Souther California
|
Posted: Fri Feb 15, 2008 9:16 pm Post subject: BAM! |
|
|
| Thank you so much. The missing PEAR packages was indeed the key. |
|
| Back to top |
|
 |
|