/    Sign up×
Community /Pin to ProfileBookmark

How to track incoming email

Hi!

By using mail() we can send emails from our servers. Thats fine.

But now I have a problem how to track incoming emails to a [email][email protected][/email] .

I think some kind of “watcher” script is needed here. But I dont know how to run a PHP file 24X7X365 hours a year without calling the file by a browser. That is in my case no one have to call that script in browser. It should be loaded when server is booting and should keep running until server is shutdown or perhaps crashed. πŸ™‚

I think that sort of script running may sometimes need Apache configs. But without going that further I’d like to know is/are there any simple alternative(s).

So if someone can let me know about such thing it’ll be a great help.

Thanks and Best Regards

to post a comment
PHP

20 Comments(s) ↴

Copy linkTweet thisAlerts:
@GUIRauthorJun 14.2005 β€”Β Hi!

What I meant from tracking emails is as follows.

"Immediately after the server receives a incoming email to certain account, by the php scritp should extract "from" , "subject" and the message.Then those paramters should be sent to MySQL DB. This should also include bounced email tracking."

Regards
Copy linkTweet thisAlerts:
@bokehJun 14.2005 β€”Β And what does that have to do with PHP?
Copy linkTweet thisAlerts:
@GUIRauthorJun 14.2005 β€”Β Hi!

I want to have a messaging script similar to a "customer support ticketing system"

Using PHP & MySQL we can keep records of outgoing emails. But when someone replies to a email sent by PHP is coming to the specifed header attributes at the mail function. And also how to assure a email sent by mail() is delivered to destination without failure. How to know (by PHP) that a mail sent by mail() has been bounced back.

What I want to do is keeping eye on incoming e-mails, extract "From", "Subject" and "Message", so PHP can then send them to MySQL.

So If I have records of both incoming and outgoing/bounced email then I can hve [b]threads[/b] like here in webdeveloper.com

Best Regards
Copy linkTweet thisAlerts:
@bokehJun 14.2005 β€”Β Those things are the job of the mail server.
Copy linkTweet thisAlerts:
@GUIRauthorJun 14.2005 β€”Β :-) You are correct. (-:

But if PHP mail() sends mail to a certain recipient then there may occasions to keep eye on replies to them and bounced email.

In more detailed, The reason I want have email messages in MySQL is to search for a certain number script-wise. Then the site admin view some info received by email by my web application without using mail client.

To further clarify all or many unread email messages should be available in one page (like you see this thread). Suppose admin receive average 5 emails from a user, and he has 20 users. Total 100 messages. So would you think its easy to switch /search them many times using mail client. What if emails pertaining to each user can be viewed at each thread.

Thats it...

Best Regards
Copy linkTweet thisAlerts:
@bokehJun 15.2005 β€”Β As I said, it is the job of the mail server. If the mail server gets a bounce it is set up to do something with it. If you have correctly configured the mailserver it will either, delete the mail, return it to the 'mail from' account (maybe not the mail but at least details) or send it to a special email that deals with errors.

Just out of interest is it the same mail server used for php and your normal mail?
Copy linkTweet thisAlerts:
@GUIRauthorJun 15.2005 β€”Β Hi!

I think the mail() uses my server. When without "From" header i shows "[email protected] .

The server is a shared hosting server. I dont know a method to configure it online. Sure it's possible. But are hosting providers provide it ? I dono.

Best Regards
Copy linkTweet thisAlerts:
@SheldonJun 15.2005 β€”Β if you only want to track emails with th php mail() code, try adding a code to add it to the database when it sends the mail? in the same process
Copy linkTweet thisAlerts:
@GUIRauthorJun 15.2005 β€”Β Hi!

Yep! I want to do that. But thats 50%- , I can send "message body", "subject", "to" to db when mail() sends email.

[b]Then the next 50% comes. If someone replies to the emali(s) sent by mail(), then the "message", "subject", "to" of that INCOMING REPLY should also go to the database.[/b]

Thats where the problem comes in.

Best Regards
Copy linkTweet thisAlerts:
@SheldonJun 16.2005 β€”Β Well all i can think of with out editing something i dont no what with your mail server settings, is IF you are using a webmail program, hack it to when it receives an email you have a button or automatically saves the message, email address and date/time to your database,

How to do this i dont no. But maybe an idea.

Else some how edit your mailserver. Contact your host?


Sheldon
Copy linkTweet thisAlerts:
@BeachSideJun 16.2005 β€”Β I don't think you can do what you are asking without doing something with the SMTP server.

The HTTP/FTP server is seperate from the SMTP server they run as seperate services.
Copy linkTweet thisAlerts:
@GUIRauthorJun 16.2005 β€”Β Hi!

I'm thinking of creating a application, perhaps for fun, even though Im not having much experience in PHP. :-)

I want to work that not only in my server, but also in any other server with LAMP. So, mail server configs will reslove the problem with my server only.

[b] But [i]Sheldon[/i], has proposed a good idea. Take a web mail program, and build my app on that[/b]. I dono is it possible, easy, hard. However I'll try to do that in my free time. Thats why opensource exists.

Sheldon, Beachside thanks for your recent replies.

Best Regards
Copy linkTweet thisAlerts:
@bokehJun 16.2005 β€”Β if you only want to track emails with th php mail() code, try adding a code to add it to the database when it sends the mail? in the same process[/QUOTE]That wont work. All php ever knows is that the outgoing mail server has accepted the mail for processing. Whatever happens after this point is the business of the mailserver and has nothing to do with php.
Copy linkTweet thisAlerts:
@GUIRauthorJun 16.2005 β€”Β Hi!

Oops Is it so.

Btw. Then how PHP webmail programmes list [b]received/bounced emails[/b] using PHP?

May be from mail server. I just want senfd email parts to db and have a PHP file which list the messages or perhaps links like Yahoo!.

May be PHP is the one who accpet the incoming emails. Is there a method to read received emails from the mail server using PHP.. ? :-) Here I've changed the original Idea (: .

Best Regards
Copy linkTweet thisAlerts:
@SheldonJun 16.2005 β€”Β That wont work. All php ever knows is that the outgoing mail server has accepted the mail for processing. Whatever happens after this point is the business of the mailserver and has nothing to do with php.[/QUOTE]


i was meaning if he was sending mail with the mail function as if from sending from a form on his web page
Copy linkTweet thisAlerts:
@BeachSideJun 16.2005 β€”Β 
Btw. Then how PHP webmail programmes list [b]received/bounced emails[/b] using PHP?
[/QUOTE]


Get one look at it and find out...
Copy linkTweet thisAlerts:
@GUIRauthorJun 16.2005 β€”Β Yep! That may be the nearest solution. :-)

Regards
Copy linkTweet thisAlerts:
@bokehJun 16.2005 β€”Β PHP is not a server! It is a scripting language run by the client from the browser or command line if and when necessary. If PHP is used for collecting webmail all it is doing is reading the mail that has already been stored on the hardddrive by the mail server. I have a mail server on my local machine and if I go to the inbox directory/directories I can open any mail there (or delete it), whoever it might be for, using either a plain text editor or an email client program like Outlook Express. If PHP also has has permission to access the same directory then it can do the same thing. A mail server does one of two things with emails: It either trys to forward them to a recipient via SMTP or if the recipient is local then it stores the file locally and waits for the client to request it via POP3. With webmail using php all that happens is a client logs in using a log in script. once logged in PHP checks with the database to see where that clients emails are stored. It then reads the directory and tells the client what is inside. If a file is deleted from that directory by PHP nothing is corrupted in the mail server because the mail server forgets about the file(email) until there is a POP3 request. It then checks the client's directory and finds it empty so returns "no messages".

As can be deduced from the above the mailserver is in charge of sending a receiving mail and PHP is only in charge of reading or deleting files from the hard drive.

In the case of error message (if the mailserver is configured to emit them) all it does is make a file in email format with an error message in it and put that in the client's mail box for later collection via POP3 (or reading from PHP webmail).

The above is just a brief outline of a mail server setup but it is impossible to know if your mailserver conforms to this model in every respect since software is written and cofigured by human beings and everyone has there own way of doing things (even when it is plain wrong).
Copy linkTweet thisAlerts:
@bokehJun 16.2005 β€”Β i was meaning if he was sending mail with the mail function as if from sending from a form on his web page[/QUOTE] Once sendmail has accepted mail from php, it is in charge of that mail and php receives no further information whatever may go wrong with its transmission.
Copy linkTweet thisAlerts:
@GUIRauthorJun 16.2005 β€”Β Hi!

Thanks a lot bokeh. Your detailed clarification educated me a lot about mailing.

:-)

Best Regards
Γ—

Success!

Help @GUIR 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.28,
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,
)...