Solved

Reveive and Intercept email in php on a windows server

Posted on 2010-09-23
2
389 Views
Last Modified: 2012-05-10
Hi,
I have php 5 installed on a windows server 2008 (IIS 6). So far I've used php to send out emails to clients but now I would like to setup an email on the server to receive & intercept incoming emails as soon as they come in  and parse them using php.

Can somebody tell me how to do that ? I am very new to this so a detailed step by step instruction would be great.

Thanks,
Ross
0
Comment
Question by:ucsdmbdm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
DrDamnit earned 500 total points
ID: 33750530
PHP is not the ideal language for this, but it can be done:

1. Create a script that binds to and listens on port 25 (see: http://www.php.net/manual/en/function.socket-create-listen.php).
2. Once you are listening to port 25, you'll need to have a loop running that processes incoming requests. Most notably, you'll want to work from the server.php example in the link I gave you above. The attached code loop will be your jumping off point.
3. You'll need to process incoming SMTP requests using standard responses (reference RFC 821 (http://tools.ietf.org/html/rfc821) and RFC 5321 (http://tools.ietf.org/html/rfc5321).

Once you have read from the socket and recieve the message, you'll be able to parse it. You might even be able to use phpmailer to parse it (http://phpmailer.worxware.com/), but phpmailer is designed to send mail more than it is for reciving and parsing mail.

Still... you could use the code in the phpmailer class as an example of how to deal with the SMTP protocol.


while($c = socket_accept($sock)) {
   /* do something useful */
   socket_getpeername($c, $raddr, $rport);
   print "Received Connection from $raddr:$rport\n";
}

Open in new window

0
 

Author Comment

by:ucsdmbdm
ID: 33771974
Thank You for the reply, I will check it out later this week.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses four methods for overlaying images in a container on a web page
Are you irritated by repeating emails issue in Microsoft Outlook 2016 after recent update ?  Lets’ see how to resolve and prevent duplicate emails in the Outlook 2016 using some simple techniques.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question