Solved

parse email with php (LDA dovcot, procmail)

Posted on 2013-01-13
3
601 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 76

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
Email signatures have numerous marketing benefits. Here are 8 top reasons to turn your email signature into a marketing channel.
In this video we show how to create an email address policy 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 Mail Flow…
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…

707 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

13 Experts available now in Live!

Get 1:1 Help Now