Solved

parse email with php (LDA dovcot, procmail)

Posted on 2013-01-13
3
606 Views
Last Modified: 2013-01-15
Using the mailparse to extract the data or use the read in nd process the input buffer one line at a time.  A better and simpler approach depending on your mail server and whether it is passing the incoming mail through an LDA dovcot, procmail. The from and the body can be extracted and presented to your php with the from and subject as arguments to your script and the body of the message as input on stdin.



I am looking to parse email with php and learn about mailservers

how would I do this
0
Comment
Question by:rgb192
3 Comments
 
LVL 77

Assisted Solution

by:arnold
arnold earned 250 total points
ID: 38772623
There are several options for mailservers on the Linux platform.  Commonly sendmail is installed by default. Postfix, exim, qmail, courier mta are some.
Postfix is somewhat simpler to configure. The install is simple with most distro.

Your question is overly broad.
0
 
LVL 3

Accepted Solution

by:
mikey1h earned 250 total points
ID: 38773672
I Think I understand that you want to  RECEIVE email atyourmailserver.  Ifso, set upan eMailaddress in sendmailthat fowards to php (my php is/usr/sbin/php) and then instal lthe attached mail class and use this code.  It will give you the sender, subject and message contents into variables in your code.

chdir(dirname(__FILE__));
require_once 'class.email.php';

// Parse incoming email from STDIN
$email = email::parseSTDIN();

//Who sent the message
$sender=($email->getSenderEmail() );
//TheMessage itself
$message = trim($email->getTextContent());
//Who the Message was sent to
$to =  ($email->getRecipientEmail());
//The Subject of the eMail
$subject = ($email->getSubject());

Open in new window




Once the email is received into the code via STDIN, you will have the following Variables...
$sender
$to
$subject
$message
mail.zip
0
 

Author Closing Comment

by:rgb192
ID: 38781312
0

Featured Post

The curse of the end user strikes again      

You’ve updated all your end user’s email signatures. Hooray! But guess what? They’re playing around with the HTML, adding stupid taglines and ruining the imagery. Find out how you can save your signatures from end users today.

Question has a verified solution.

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

Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
The viewer will learn how to dynamically set the form action using jQuery.

910 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now