Re: Re: verification of mail success
| From: | Mattias Thorslund | Date: | Fri, 24 Feb 2006 01:52:29 +0000 |
| Subject: | Re: Re: verification of mail success | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-230996@lists.php.net to get a copy of this message | ||
Manuel Lemos wrote:
> Hello,
>
> on 02/23/2006 09:22 PM mattias@thorslund.us said the following:
>
>> This might be "too simple" or not...
>>
>> I'm trying to send emails from my PHP page, and while both mail() and PEAR Mail
>> work, I'm having a hard time finding out whether a message was actually sent or
>> not.
>>
>> With both mail() and PEAR Mail, an email to an invalid domain (syntactically
>> valid) name returned "success"... Running mailq at the command prompt gives me:
>>
>> "(Host or domain name not found. Name service error for name=activeagenda.org
>> type=MX: Host not found, try again)"
>>
>> Basically, I'd like my PHP script to know of issues like these.
>>
>
> What you want is impossible most of the time. The problem is that
> usually applications are MUA (Mail User Agents) and so do not deliver
> messages. They rather queue them in the MTA (Mail Transfer Agent) queue.
> So you only know whether the message was successfully deliver or not if
> you request some kind of delivery notification.
>
> Alternatively, if you want to know whether an address is valid, you may
> want to try this e-mail validation class.
>
> http://www.phpclasses.org/emailvalidation
>
> You may also want to try this other class that can act partially as an
> MTA. It is a normal mail composing and sending class with a SMTP
> delivery sub-class that has a direct delivery mode. This means that it
> will attempt to send the message directly to the destination SMTP server
> rather than queueing in the local MTA queue.
>
> It comes with a wrapper function named urgent_mail(). It is compatible
> with the mail function, except that it uses the class direct delivery
> mode to attempt to deliver the message right away. If it fails due to
> some temporary error, it falls back to the mail() function.
>
> http://www.phpclasses.org/mimemessage
>
First, thanks for quick replies, everyone!
Manuel: I'll look into the mimemessage class.
Yes I'm aware of the mail queue. I guess what I'm after is way to get a
more detailed status message. I notice that in the mail queue, each
message is given a unique ID, which I suspect could be used for my
purpose, i.e. has the message been processed yet, is there a temporary
or permanent delivery problem, etc. I don't see how the PHP function
would be able to get the message ID of the message it just handed over
to the MTA.
I guess one way would be to implement a queue of my own, and use the
"direct SMTP" approach to deliver messages.
/Mattias