Solved

PHP Script to Receive Email

Posted on 2008-06-18
5
1,838 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 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

718 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