473,721 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checking messages sent with mail()

I use the following code to send e-mails with PHP:

if(@mail(....))
{
//Send OK
} else {
//Send Bad
}

But how can I verify that a message was really sent (in case of "Sent
OK)?
I mean, mail() "returns TRUE if the mail was successfully accepted
for delivery", but this is not a guarantee that the message left the
server (i.e. was sent).
How can I check that?
Of course I already tried to send e.mailto my.self and works but how
can I check any exception or error?

Thank you very much for your reply.
Gio
Jul 17 '05 #1
4 2236
"Giobibo" <gi*****@yahoo. com> wrote in message
news:ms******** *************** *********@4ax.c om...
I use the following code to send e-mails with PHP:

if(@mail(....))
{
//Send OK
} else {
//Send Bad
}

But how can I verify that a message was really sent (in case of "Sent
OK)?
I mean, mail() "returns TRUE if the mail was successfully accepted
for delivery", but this is not a guarantee that the message left the
server (i.e. was sent).
How can I check that?
Of course I already tried to send e.mailto my.self and works but how
can I check any exception or error?

Thank you very much for your reply.
Gio

Specify a return path, and check the return account, either by pop'ing the
box or by having a script filter any email to that account.

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #2
On Wed, 17 Mar 2004 09:17:32 GMT, "CountScubu la"
<me@scantek.hot mail.com> wrote:

Specify a return path, and check the return account, either by pop'ing the
box or by having a script filter any email to that account.


Thank you very much for your reply.

Please could you give more details, I do not understand what does
mean:

"pop'ing the box" or "a script filter any email to that account"

Thanks again
Gio

Jul 17 '05 #3
There is no convinient way to check reception, unless you are able
to check recipient account, what has been suggested in one of the
answers.

There is one thing that you can do. mail() function connects to uotgoing
server and expects it to deliver the message. Perhaps you can find a way
to ensure that message issent without queing, which is, I belive,
possible with sendmail, and some other mail servers on UNIX systems, or you
can open use sockets to:

- query DNS to determine the mail host for recipients domain
- send message via SMTP

I think that sendmail ha switches for sending message without queue-ing,
and you should pipe the message to standard input of sendmail process.
I don't know right now what the command switches are, you will have to
check sendmail documentation.

--
Ask yourself: are you ready for the enterprise ?
Jul 17 '05 #4
"Giobibo" <gi*****@yahoo. com> wrote in message
news:57******** *************** *********@4ax.c om...
On Wed, 17 Mar 2004 09:17:32 GMT, "CountScubu la"
<me@scantek.hot mail.com> wrote:

Specify a return path, and check the return account, either by pop'ing thebox or by having a script filter any email to that account.


Thank you very much for your reply.

Please could you give more details, I do not understand what does
mean:

"pop'ing the box" or "a script filter any email to that account"

Thanks again
Gio


Ok, when you use the mail() command, php is not sending the mail, but rather
passing it to the local mailer. (i am assuming sendmail/linux)

If the email can not be deliverd, it is sent back to the Return-path:
email@address , this can be your valid email address, and you will get all
the email that can not be sent. or you can also do these things:

1) Have the email address have its own email box, and you can pop it, by
this I mean, you can log in and check it with a mail client or a php script.

2) when the email arrives to this email adress, have sendmail pass it to a
php script, and have that script look it over and see why it came back.

I have sent up a AOL mailing listserver, for a client, and all the mail that
bounces back goes into a server, and that server checks why it was not
deliverd, if it was becouse the user doesnt exist, then it removes them from
the database, if there mailbox was full, it tries to redeliver at another
time. and so on....
As someone pointed out you can try a direct deliver, I have written a
framework for this, it is really simple to use, and you will know if the
mail was sent, and if not, you will have a good indication of why.

http://www.gzentools.com/snippetview...l&v=mxmail.php
--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3662
by: Damien | last post by:
Hello to all, I've written a script that take quite a long time to execute (email sending). Last time I ran it, PHP gave me a "execution time limit exceeded" (or something like that), so I changed the value in php.ini. Now, the questions are : - How can I make sure I'm not going to have problems when execution time lengthens still ? I'm afraid to set too high a time limit in case other scripts run astray. - Can I "break" the job into...
5
1823
by: Dylan Parry | last post by:
Hi, I am by no means a Python programmer, but I am dabbling with it and trying to create a simple program that reports how many emails I have to download. So far, using the poplib extension, I have got: def checkEmail(): email = poplib.POP3('mail.mydomain.ext') email.user('user') email.pass_('password')
3
4355
by: Yorn Ziesche | last post by:
Hi everybody, i try to send messages longer than 7990 characters from a text field in SSQL2000. Unfortunatly the messages get cut off after 7990 character. I did everything which is described in BOL (see below). It does not solve the problem. Upgraded to newest Outlook Client and tried to send as an attachment also. No success though.
3
1879
by: Riku Kosonen | last post by:
Hi, We have some problems with sending mail with the SMTP service on IIS (Windows 2000). We use the ASP.NET platform and have an ASPX-page that sends different mail messages to about 1000 clients. After some tests we found out that in one test some messages didn't arrive at all to the recipient. All logs state that the operation went nicely (no errors, no bad mail in the mailroot, etc.). We suspect that the target mail server (all...
16
2628
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project where someone suggested to me I was spending too much time writing error messages, and that I was therefore missing the benefit of using a scripting language. The idea, apparently, is that the PHP interpreter writes all the error messages that are...
0
1154
by: yash518 | last post by:
Hi friends, I am using the AJAX to call a method on the server which sends a mail to the user. I am using struts' action class to send the mail. After sending process complete I am saving action messages and returnig mapping.findForward("") I I am calling the AJAX method, the mail is being sent to the user but the class is not returning messages. The browser displays this messsage. This XML file does not appear to have any style...
1
1911
by: halcyon943 | last post by:
have 4 folders that I watch and need to move files from to another location. Three constraints: -Finish time. Make sure the program stops transferring files at a specific time -Number of files transferred. Can only move a certain amount of files per time period. -Folders have a priority. The files have to be moved based on the folder priority.
18
2385
by: Grant Edwards | last post by:
Could whoever is responsible for the gateway that is grabbing my postings off of Usenet and e-mailing them out please fix the headers in the mail messages so that I don't get the bounce messages? While you're at it, might as well fix it for everybody else too. ;) Its a bit rude to send out mass e-mail messages with headers faked up so that the bounce messages go to somebody else.
0
1147
by: skip | last post by:
RonI think most of us are annoyed by the recent SPAM messages that Roncrept onto our list. I'd like to suggest a possible solution, and Ronmaybe start a thread that eventually will rid us of this Ronunpleasantness. RonMy idea: RonOnce every few messages from the list owners, they would send a new Ronnumerical string that will have to be included in members' list Ronsubmission. A message being submitted without this numeric string
0
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.