Can emails come into a PHP / SQL database?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Can emails come into a PHP / SQL database?
Hi.
We need to collate emails that are coming in, into PHP and a database. So we can collate email addresses.
Facebook does it - you email name@facebook.com and it will go into your Messages on your Facebook account.
I assume it's done with something else in the email address - but how??
We need to collate emails that are coming in, into PHP and a database. So we can collate email addresses.
Facebook does it - you email name@facebook.com and it will go into your Messages on your Facebook account.
I assume it's done with something else in the email address - but how??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Can emails come into a PHP / SQL database?
Email is just text. You can process it however you want. There are several ways to access a mailbox and extract the text using PHP. I prefer using the IMAP functions. This allows you to access mail on remote servers and is more portable code.
But in the old-school simplest way: you could also setup an email pipe for a specific email address (like help@domain.com) on your server which tells your mail server to send the email directly to a PHP script. You can then parse everything directly.
But in the old-school simplest way: you could also setup an email pipe for a specific email address (like help@domain.com) on your server which tells your mail server to send the email directly to a PHP script. You can then parse everything directly.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Can emails come into a PHP / SQL database?
My god I never knew that!
So do we have to tell the mail in Plesk 11 for a particular account to handle it differently? Basically, what is stopping Plesk (or whatever it is in the mail system) from handling it in the "default manner"?
I get that I could capture the data in the email, but how do I send the email to PHP (ie. domain.com/emailhandler.php) rather than the normal method?
So do we have to tell the mail in Plesk 11 for a particular account to handle it differently? Basically, what is stopping Plesk (or whatever it is in the mail system) from handling it in the "default manner"?
I get that I could capture the data in the email, but how do I send the email to PHP (ie. domain.com/emailhandler.php) rather than the normal method?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Can emails come into a PHP / SQL database?
You can either setup the IMAP functions to access whatever email account you've setup on the server, or you can setup the mail server (via Plesk) to pipe specific emails to a PHP file that parses it.
Your facebook.com example doesn't help me understand what you want to do. Do you expect to use just one incoming email address that you want to configure a mailbox for? Or do you want to have anything sent to your domain processed/saved?
Usually a mail server allows you to specify what to do with emails that have no accounts configured at that domain. You can then specify to pipe them to a PHP file. This way any_random_address@yourdomain.com will be sent to the same script.
Your facebook.com example doesn't help me understand what you want to do. Do you expect to use just one incoming email address that you want to configure a mailbox for? Or do you want to have anything sent to your domain processed/saved?
Usually a mail server allows you to specify what to do with emails that have no accounts configured at that domain. You can then specify to pipe them to a PHP file. This way any_random_address@yourdomain.com will be sent to the same script.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Can emails come into a PHP / SQL database?
At the moment I'm not exactly sure. I think it's because we are getting those "email address doesn't exist" emails back, and would perhaps like them into a PHP script to query the email that failed and remove it from our database of emails.
But I'm not sure if these bounce backs are possible to collate via PHP.
But I'm not sure if these bounce backs are possible to collate via PHP.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Can emails come into a PHP / SQL database?
Your mail server usually has the ability to process undeliverable mail in any way you want, including sending a bounce message or just ignoring/deleting it automatically...or passing it on to a PHP script to do something more complex with the undeliverable message.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Can emails come into a PHP / SQL database?
We want to send that undeliverable (because it is fred@fred.com for ex) to a PHP script, so we can collate the email in there and add it to our exclusion list.
What setting in Plesk should I be looking for, to set this up for a particular email? As I assume those come from a DAEMON address?
What setting in Plesk should I be looking for, to set this up for a particular email? As I assume those come from a DAEMON address?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Can emails come into a PHP / SQL database?
Talk to your host provider. You want to "pipe undeliverable messages to a php script". I don't know how to configure that in Plesk. If you used cPanel I could tell you.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: Can emails come into a PHP / SQL database?
Done that - out of interest, where is it in cPanel, as we have one site that does use cPanel so if I can see it, I might know where to find it in Plesk 11.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: Can emails come into a PHP / SQL database?
I'm not a fan of Plesk. I almost always end up doing everything over SSH.
cPanel: http://docs.cpanel.net/twiki/bin/view/A ... lFowarders
cPanel: http://docs.cpanel.net/twiki/bin/view/A ... lFowarders