Click to See Complete Forum and Search --> : php receive and parse email.
tommytx
07-26-2005, 10:42 PM
Can anyone guide me to a good place to get info on using php to receive the email, parse it for something like 0502473 and 0503467 etc in the subject line and then send back a response to the sender of the email based on all the numbers in the body with 050 sequence etc.
I have looked at a lot of articles, but they all seem too complicated for me to understand. I don't have a problem with sending email, just receiving. I would set up a special email box to receive this mail and no other mail so every email received would be looking for a response depending on the 050 series numbers in the subject line.
So... bottom line is I need to know how to receive and parse an incoming email and I can handle the rest. I would even buy a commercial program if it would work and could be called by a php program.
Thanks in advance.
Tom
CompGeek01
07-27-2005, 09:08 AM
Are you familiar with UNIX commands at all? Is your server UNIX or Windows?
You can't natively respond automatically to emails, but you can set up a "scheduled task" or "cronjob" to run a php script every few minutes.
Using the IMAP functions within php to download the mail and then use regular expressions to search the mail for key words...then respond.
It's complicated but if you get started, shouldn't be too hard to get you through.
tommytx
07-27-2005, 12:47 PM
I have tried to figure out php for this but do not understand it well enough to receive an email. Am looking at perl now, seems to be simpler to deal with email. I am pretty fluent in perl and php.
If anyone has any code to receive email that I might understand, I would be very pleased. That is sample code that works.
CompGeek01
07-27-2005, 02:13 PM
I'll try to put something together when I get home from work. No imap extension here. Not much through Google. Do you have an imap or pop mail server?
tommytx
07-27-2005, 02:35 PM
I have all pop3 accounts. Not sure if they are also Imap too but they may have that capability also. However, as a last resort I would even use the outlook express to place the specific incoming mail that qualifies in a special directory and then activate an outlook script to process it. I played with outlook and when it came to programmng the script when it says where is your script located, I can't find the directory to place a script to be run by the outlook script that selects the emails and places then in another directory. That is when you go under outlook and tools and Rules Wizard. I would prefer stand alone though, as I don't want to have to keep outlook on line unless I have to 24 hours a day.
There is a lot of stuff on receive email via php, but so far I have not been able to understand it.
Thanks for the help.
Tom
bokeh
07-27-2005, 03:46 PM
You didn't answer CG01's question. Are you using a windows or linux server. This is important as you can only set up cron jobs on a linux server (although there is psuedo cron for windows). Secondly if your webserver and mail server are on the same machine you should be able to access the emails directly just by using file commands (although this is unlikely on a shared server. My recommendation would be have all emails delivered to one mailbox by the mail server and then have php sort them after they are downloaded from the mailserver. That way if you have to use POP3 you will only have to access one mailbox making both the PHP script and the cron job a lot simpler.
tommytx
07-27-2005, 04:25 PM
I am pretty sure I am linux as I must do the permission 777 on each php file I upload to the web and I don't believe windows requires that. Also I can use an email on the same server, as I have the capability to set up 25 emails and I am not shared hosting UGH! I have one of those and don't like it.
So I should be Linux, pop, non-shared and don't need to worry about cron now, just want to figure out how to receive and parse an eamail just the basic code and I can do the rest. I have been studing perl which looks easier, but have fell in love with php and want to do it with php if possible..
Thanks
Tom
bokeh
07-27-2005, 04:42 PM
So if it is non shared you must own the server. Is that right?
tommytx
07-27-2005, 08:11 PM
So you have not yet heard of shared IP's on hosts, I hate sharing IP.s with others and I don't think google likes them either. I only use one server that has shared IP,s they are cheap but I won't use another on.
bokeh
07-28-2005, 01:41 AM
Using name based virtual hosting as opposed to IP based virtual hosting is a good thing for the internet in general and it certainly will not affect your listing at google. Name based virtual hosting was introduced with the HTTP 1.1 standard as there are only 4 billion IP4 addresses and this is less than the planet's populous. The only time IP based virtual hosting is necessay is for using multiple SSL certificates on one server. This is because the SSL connection is established before the header (name) information is sent hence the certicate must be chosen based on the IP the client is connecting on.