phpprocessforwardingincoming-mail

Receiving and Processing Incoming Emails with PHP


I want to setup an environment, where users send an email to mobile numbers with fix domain name, for ex. 12345678@somedomain.com and I will read all the incoming emails coming to my somedomain.com.

Now further, I will already have user information with same mobile number, and will forward received email to that user on his specific email address.

Now, what I want to know is:

1] Does anyone know or already have implemented in PHP, how to check or read / process incoming emails as I get them, may be with SMTP or POP3 or IMAC protocol and further forward same email to specific users.

2] What should be the standard server environment requirement for this. I mean Windows server with some pre-installed services or ports opened, or Linux server could be a better environment for this functionality.

I tried to search over many protocols like Procemail, Sendemail open source resources, however not getting proper help to understand thoroughly.

I see some similar questions, though asking with my specific details and functionality to develop in future. Hope it will be okay.

Earliest response will be appreciated.


Solution

  • 1) You can setup 'catch-all' email for incoming messages so all email will land there. For accesing emails you can use POP3 or IMAP which are supported by PHP: some example: link. SMTP is for sending emails.

    To read emails you would have to setup CRON job that periodically checks your master account for new messages - just like any other email client.

    2) If you must setup own mail server use Linux with Postfix/Dovecot great tutorial for Debian but you can use PHP to just access mailbox and process new emails.

    To send emails you can use some library (I've recently used Zend Mail component and it works great ).