View Full Version : Incoming emails to a mailing list

05-22-2008, 08:56 PM

I have been asked by a customer to see if i can create a script which takes an incoming email and take the email and contact details into a csv or excel or database to populate a mailing list?

Is this easy to do with PHP ? and how do you grab that information?

05-23-2008, 05:39 AM
when you say incoming e mail do you mean via a web form or just mail into a mail program?

05-23-2008, 05:44 AM
It would be from a mail program like sendmail.

05-23-2008, 05:53 AM
sorry i said that wrong I meant like outlook or the like. If it is a web form you could take the post values of address and name and add an insert into a database table in your form handler,

05-23-2008, 05:57 AM
Yeah outlook or any mail system.

05-23-2008, 06:03 AM
that would be in the programming of the mail program I dont see how you could use php in that case

05-23-2008, 07:44 AM
Yes this can be done, you would need to look at the PHP IMAP functions, hint http://uk.php.net/manual/en/function.imap-open.php

You would need to create a new POP3 account just for this and then run a cron to check for new emails every hour or so then process with PHP. The only problem would be is how to you extract the details? If you are extracting body text such as a user entering their address in the message body that could be a problem because you could receive spam or something entirely different.

If however you were just extracting header info then that is far easier.

You might have experienced similar when emailing a web host for customer support where you get a support ticket automatically assigned, they use the same concept but I think Perl tends to be the language of choice.

05-27-2008, 10:11 PM
Thanks Pete. I will have to do some more research, it would be the email address and subject line.