?
Solved

How to add info to MySQL when an email arrives?

Posted on 2003-03-18
10
Medium Priority
?
185 Views
Last Modified: 2006-11-17
I want that everytime that someone sends an email to problems@mydomain.com to run some kind os script that put the info of that info in a table and resond to the sender sending a Case ID number, How can I do this?

I know that I can edit the aliases file to run an script when an emails is received to an spaceific address but I dont know how to get the info of that sender and reply him.
0
Comment
Question by:matrix717
[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
10 Comments
 
LVL 15

Expert Comment

by:VGR
ID: 8162830
classical question. PHP can't do this alone. PHP can't react to SMTP events. You've to use a twisted version of the sendmaild (queing, etc).

On *nix it's rather easy.

On Windows I did not find the way yet 8-)
0
 
LVL 2

Expert Comment

by:bobsledbob
ID: 8164552
VGR is mostly right.  Using PHP for this doesn't seem right.  However, if you have a CLI (command-line) or CGI version of PHP, then you in theory could use PHP to do this.  If you do have this, then simply writing a script like this should work:

#!/path/to/php -q  // -q for CGI version, not for CLI version
<?php
  // do some magic here, like checking for environment
  // variables set by mail program.
?>

Of course, you're going to have to check for the environment that sendmail sets up, since this will contain the header and body of your email message.

Overall, you're barking up the wrong tree.  PHP is not the solution for you.  There's plenty of open-source off-the-shelf solutions that will do this for both *nix and windows.

Adam
0
 
LVL 15

Expert Comment

by:VGR
ID: 8164774
could you name a single one free (and good :D ) for Windows and (if possible) cross-portable to linux ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:bobsledbob
ID: 8164958
Search for "Microsoft Exchange Server Scripting Routing" on google.

http://www.google.com/search?q=Microsoft+Exchange+Server+Scripting+Routing

=)

At least that's a start.  I think you're dreaming for 'cross-portable' though. ;)
0
 

Author Comment

by:matrix717
ID: 8167859
I need one for Unix...
0
 
LVL 15

Accepted Solution

by:
VGR earned 252 total points
ID: 8168321
for unix, the sendmail most encountered is enough. Look in its options. It's able to invoke php (as CGI-Bin : php -commandline) upon receiving an email to specific addresses
0
 
LVL 2

Assisted Solution

by:bobsledbob
bobsledbob earned 248 total points
ID: 8168614

Also, I was thinking last night, you might want to use 'procmail' to help you out.  It's 99% of the time bundled with sendmail, so you should likely have it.  Do a 'man procmail' to read about it.

Basically, you can set up procmail rules to help process incoming email.  Then, you can make logical decisions on what to do and can alliviate some of the problems you're going to have with parsing the email, passing the parameters off to some program, etc.

There's got to be a perl program that does what you're looking for.  A quick search through CPAN should get you there.

I think between my advice and VGR's, your question is basically answered.

Hope this helps.

Adam
0
 
LVL 3

Expert Comment

by:prady_21
ID: 8172226
if i have not mistaken you, you want to respond to a mail, the mails coming at you@somedomain.com
Well as you said, you can do it by aliasing and running a script. I did this in perl, so i dont know if that helps??????
The shell gives the contents of the mail to the script, so the script can read the contents and get the From: address of the user, and then you can reply back to the person.
So if you need any help, see the book Sendmail by O'Reilly, if you can do it in perl, it is easy
Hope this helped you



0
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 11934760
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
    Split: VGR {http:#8168321} & bobsledbob {http:#8168614}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

snoyes_jw
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses

762 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