Solved

Reply to E-mail that came form webiste? Then Track it back into website?

Posted on 2011-09-09
7
266 Views
Last Modified: 2013-12-18
You've received an e-mail before from a ticketing system or a website messaging... where it says "You can reply directly to this e-mail" instead of logging back into the web site to send the message. How do they do this?

My server is a Linux, running Apache2.0, PHP 5.3 (upgrading atm),  Qmail mail/Sendmail.... Where do I start?
http://test.ahaworldcampus.com/phpinfo.php

Even just an article or something... or a keyword to put in google because I can't even figure out what to search for, lol.

Thanks!
0
Comment
Question by:tonyhhisc
[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
  • 2
  • 2
7 Comments
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 36511025
Do you want to "post" the email to the website?  Such as this:

http://codex.wordpress.org/Post_to_your_blog_using_email
0
 

Author Comment

by:tonyhhisc
ID: 36511175
Yes that's pretty much the same thing I'm looking for. But of course I'm not using wordpress.

The functionality of sending an e-mail to create a post (or execute a function) on my web site is what I'm looking for.

I want to send an e-mail to:

someaddress@myserver.com

Maybe with the subject line containing "[9282-9424] RE: blah blah"

I've seen it done like that before.... I think the [9282-9424] is the id of the message and the user id. As long as that's in the subject line, it will post everything back to the website.


0
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 36512266
The content management systems do this type of thing and they add lots of bells and whistles, many of which you will probably want such as screening out words, large posts and other thing you might not want posted on the web site.  Also they handle security as this can be a easy hole to hack.  If you want to write your own, plan on it being a big project.  I'd look at some of the opern source CMSs that do this and see what the code does.  Here's a link that talks about it:

http://www.phpbuilder.com/board/showthread.php?t=10353564
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 36516230
The thing you want is called an email pipe script.  It is an script that is started automatically by the server whenever email is received at a certain email address.  The pipe script gets access to the entire email message, including all headers.  The pipe script can then take information from the email and use it to process the contents of the message.  

In the example with a subject containing [9282-9424] that string of numbers is a unique id that enables the pipe script to find a row in the data base.

The pipe script can do anything that any other PHP script can do - read and write to the data base, etc (see line 55).  However because it is started asynchronously it does not have any place to put browser output.  Thus debugging can be troublesome.  The example in the code snippet shows how I have used the mail command with a pipe script.  In that design pattern I am able to see what the pipe got for input, as well as any messages I might want to issue from the pipe script.  Parse errors, obviously, are hard to detect, so rely on your error_log to find those.

HTH, ~Ray
#!/usr/bin/php -q
<?php // /email_pipe/index.php


// THIS IS AN EMAIL PIPE SCRIPT.
// THIS SCRIPT IS STARTED AUTOMATICALLY FOR EACH MESSAGE.
// NOTE THAT THIS SCRIPT IS ABOVE THE /public_html/ DIRECTORY TO PREVENT ACCIDENTAL EXECUTION


// --> HOW DO WE KNOW WHICH EMAIL MESSAGES GET SENT HERE?
// THIS SCRIPT RECEIVES MESSAGES SENT TO email_pipe@your.org
// CREATE AN EMAIL MAILBOX EXCLUSIVELY FOR AUTOMATED PROCESSING.
// SET UP AN EMAIL FORWARD FOR THAT MAILBOX IN cPANEL->EMAIL LIKE THIS:
// 1...5...10...15...20...25...
// |/home/{account}/email_pipe/index.php


// --> WHEN YOU UPLOAD, THIS SCRIPT WILL BE MARKED RW-R-R BUT THAT IS WRONG
// THIS SCRIPT MUST BE MARKED EXECUTABLE x0755
// YOU CAN USE FTP SOFTWARE TO CHMOD TO RWX-RX-RX


// --> NOTE THE FIRST LINE OF THIS SCRIPT MUST SAY #!/usr/bin/php -q STARTING IN COLUMN ONE
// 1...5...10...15...20...25...
// #!/usr/bin/php -q
// <?php ... PROGRAM CODE FOLLOWS


error_reporting(E_ALL);

// USE THE OUTPUT BUFFER - THIS DOES NOT HAVE BROWSER OUTPUT
ob_start();

// COLLECT THE INFORMATION HERE
$raw_email = NULL;

// TRY TO READ THE EMAIL FROM STDIN
if (!$stdin = fopen("php://stdin", "R"))
{
    echo "ERROR: UNABLE TO OPEN php://stdin " . PHP_EOL;
}

// ABLE TO READ THE MAIL
else
{
    while (!feof($stdin))
    {
        $raw_email .= fread($stdin, 4096);
    }
    fclose($stdin);
}


// REMOVE MULTIPLE BLANKS - AND OTHER PROCESSING AS MIGHT BE NEEDED
$raw_email = preg_replace('/ +/', ' ', $raw_email);

// SPEW WHAT WE GOT, IF ANYTHING, INTO THE OUTPUT BUFFER
var_dump($raw_email);

// CAPTURE THE OUTPUT BUFFER AND SEND IT TO SOMEONE ELSE VIA EMAIL
$buf = ob_get_contents();
mail ('you@your.org', 'EMAIL PIPE DATA', $buf);
ob_end_clean();

Open in new window

0
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 36529331
Good answer Ray.  I'm curios though.  How is the script started?  Does the mail server tell apache to run it?  
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 36529489
Yes, I think that is how it works (haven't used one in a while).  See lines 10-15 of the code for how I set it up.  If you don't have cPanel, your hosting company can probably set it up for you.
0
 

Author Closing Comment

by:tonyhhisc
ID: 36530388
Excellent!! Many Thanks!
0

Featured Post

Webinar: MongoDB® Index Types

Join Percona’s Senior Technical Services Engineer, Adamo Tonete as he presents “MongoDB Index Types, How, When and Where Should They be Used?” on Wednesday, July 12, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7).

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
In this video we show how to create a mailbox database 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 Servers >> Data…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

623 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