Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

parse email with php (LDA dovcot, procmail)

Posted on 2013-01-13
3
Medium Priority
?
633 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
[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
3 Comments
 
LVL 79

Assisted Solution

by:arnold
arnold earned 1000 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 1000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

715 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