Solved

PHP Script to Receive Email

Posted on 2008-06-18
5
1,822 Views
Last Modified: 2013-12-13
Hi,

System Requirement: Windows Server 2003

I need a php script running on this web server to receive emails. Ideally, there would be an email system installed on the web server.

Method 1 (preferred): When an email is received by the email system, a php script is invoked which processes that email.

Method 2: A php script is periodically invoked that checks for email from an email server (local or remote).  

One way or another, I need to receive email with php.

Any tips?

Thanks for your time
0
Comment
Question by:oxygen_728
  • 2
  • 2
5 Comments
 
LVL 49

Assisted Solution

by:Roonaan
Roonaan earned 300 total points
ID: 21816081
There are several mail server which run on mysql. You might be able to use a Sceduled Task to run a php script to either use php pop/imap functions, or tap directly into mysql.

For php mail check functions you can of course also use a non-mysql mailserver and use pop or imap.
0
 

Author Comment

by:oxygen_728
ID: 21816119
Roonan, thanks for the tips.

Do you know a good mail server for a windows server that can invoke a script or executable when an email is received?

Thanks for your time
0
 
LVL 49

Assisted Solution

by:Roonaan
Roonaan earned 300 total points
ID: 21816156
I'm not an expert on the mailserver world, so can't realy suggest one. I like the setup of the Sceduled Task or Cronjob, as it is mailserver independant which allows my application to shift to another (mail)server more easily, and allow my php server to run from another machine than my mailserver.
0
 

Author Comment

by:oxygen_728
ID: 21816175
Roonan, I understand - my main concern is that I have a larger process of which this is just a small part. So if I have a scheduled task that operates once per minute, then that will slow down the entire system. And I'd be nervous about scheduling the task too fast... with windows being the way it is

0
 

Accepted Solution

by:
kevinx24 earned 200 total points
ID: 21994577
oxygen,

You may be able to do this using a hosted service, Email2HTTP (http://www.email2http.com).

This will allow you to handle mail by simply writing a script that handles a form POST.   Parts of the email would be delivered to your PHP script as form post variables, like $_POST["subject"], $_POST["body"], etc.

See code sample taken from Email2HTTP website:


<?php
 
// Save each attachment from the message to disk
foreach ($_FILES as $attachment)
{
	move_uploaded_file($attachment["tmpname"],
		"../files/" . $attachment["name"]);
}
 
// Send a reply back to the sender by email
// by simply producing some output
$numberOfFiles = sizeof($_FILES);
echo "Thank you, my friend.  I have received your "
	. $numberOfFiles . " files."
	. "\r\n\r\n---Original message---\r\n"
	. $_POST["body"];
 
?>

Open in new window

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

856 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