?
Solved

PHP Script to Receive Email

Posted on 2008-06-18
5
Medium Priority
?
1,841 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
[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
  • 2
5 Comments
 
LVL 49

Assisted Solution

by:Roonaan
Roonaan earned 1200 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 1200 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 800 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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 a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

765 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