Run PHP script when new email received


 
Thread Tools Search this Thread
Operating Systems Linux Run PHP script when new email received
# 8  
Old 10-14-2010
In many implementations, if properly configured, and the local security model allows, a .forward file in your home dir can contain '|command_string', in which case every email coming in gets processed by that command, potentially parallel instances for multiple messages, so be careful what you script.

If this is not acceptable, you have to poll the email file or mail commands, unless you shut down the normal mail server, and your web server also listens on port 25 as smtp/esmtp email server. It could send any unrecognized email to another email server/host to deliver, or file it. SMTP/ESMTP is a pretty easy protocol; just Google for RFC SMTP or RFC ESMTP and find the nice wikis and such. You can also look at raw email messages to see examples of how messages are formatted, in case you want to forward them via email (by tcp connection to port 25 on a different host, as you are now the entire local email service).
# 9  
Old 10-14-2010
Most systems permit the .forward file by default. You should not need "polling" or anything more complex than a single entry in the .forward file.

Just test it and see if it works! It should, if you have it configured properly.

If you do a Google search on SMTP mail and the .forward file, you will see that this is normally enabled, by default.
# 10  
Old 10-14-2010
Just watch out for the security audit! My last Solaris system had it turned off. The .forward wiht pipe is one "non-polled" solution, but to scale up with lower overhead, taking over port 25 saves all the fork and exec overhead. Of course, in the end, the port socket fd will be "polled" by poll or select unless it gets its own thread! It turns out there is often a layer of polling even in interrupt-related mechanisms, sometimes in the kernel! After all, what we call UNIX is mostly what UNIX calls Time-Sharing! Smilie
# 11  
Old 10-14-2010
Well, it is a bit premature to discuss 'security audits' when:
  • You don't know even if it works.
  • You have no idea what their organizational security policy is.
  • You have no idea even if they have security policies (LOL).
  • You have no idea what is the purpose of the server or this application.
  • You have no idea what the risk model is for the organization.
  • You have no idea what is the risk model for anything in the poster's world.

One the things that is very important here at The UNIX and Linux Forums is to not make a bunch of assumptions that may or may not apply to others.

In fact, upon review, the OP said:

Quote:
I have a web site hosted with a cPanel web host.
So all he needs to do it try it by editing the .forward file and trying to forward to another email address.
# 12  
Old 10-14-2010
Technically unacceptable is somehow worse than Politically unacceptable? Many milieu are very security concsious, and more are getting more so every day; many nice features are being turned off, so the wise user includes the local security culture in their tool choice process. Everyone should have at least a virtual seat at the design table: Security, Testing, Admin, Production Support, Configuration Management, Legal, all levels of Users as well as Management and Development.

Of course, if we had better requirements . . . . They say even a very dumb engineer can design and implement from good requirements, but writing good requirements takes a very good engineer.
# 13  
Old 10-14-2010
I have no idea what you are talking about, DGPickett (Sorry). This does not need to turn into a political discussion. The poster asked a very simple question.

Using .forward in a users own directory on a shared server (where they are not a privileged user) is not a giant security hole that is such a high risk.

Let's keep this conversation on track and don't create a bunch of "security requirements" and "risk" that don't exist.



The question has been answered. Time to move on.
# 14  
Old 10-14-2010
I do not set the security requirements, I just design in harmony with them.

Someone hates that .forward pipe, and once it is maligned, managers will start turning it off as part of a comprehensive security audit remediation.

I guess you are in "last word I fixed it" mode, not "ask the user if they are fixed yet" mode. Customer focus is not at political discussion. It is good design.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Adding a blank line in between two O/Ps in tabular format which gets received over email

Hi Guys, I am stuck in between and seeking help here. Requirement: A script that will run every morning which will connect to Mysql database and run the query to inform us about the holidays (it will also check if there were any holidays during last 2 business days). So the three queries are... (11 Replies)
Discussion started by: Sambit Sahu
11 Replies

3. Shell Programming and Scripting

How to check email with attachment received or not from UNIX shell script?

Hello Guys, Here is the requirement!! I want to check the mail with attachment received or not through unix scripting. And send an notification email when mail with attachment already received. Any thoughts on this is much appreciated!! Regards, Harry (0 Replies)
Discussion started by: dharry2017
0 Replies

4. Forum Support Area for Unregistered Users & Account Problems

No activation email received

I have tried to register today with the username BatterBits, but have not received the activation email I do not live in any of the restricted countries - unless the UK has suddenly become a threat! I'd be grateful if you would assist. many thanks Ian (2 Replies)
Discussion started by: unregistered
2 Replies

5. Shell Programming and Scripting

Run a script when I receive an email

Hi expert I wish to start a shell script when I receive an email. I modified the aliases file and I add this string as400nag: "|/home/nag-script/startstop/AS400-Boot.sh The solution works . When the as400nag user receive an email the /home/nag-script/startstop/AS400-Boot.sh starts .but... (3 Replies)
Discussion started by: emi65
3 Replies

6. UNIX for Advanced & Expert Users

problem on email sent but not received

hi.. I have the porblem where the email was sent but not received by users.. The message as below:- Dec 16 11:42:04 isp postfix/smtp: A80042B4B: to=<user_name@example.com.my>, relay=smtp.example.com.my:25, delay=890, delays=0.17/0.02/31/859, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued... (1 Reply)
Discussion started by: bh_hensem
1 Replies

7. Forum Support Area for Unregistered Users & Account Problems

no email received

I have tried to register and got a message saying an email would be sent but no email has turned up. Could you try again please? (1 Reply)
Discussion started by: lookingfor help
1 Replies

8. UNIX for Dummies Questions & Answers

run a script from incoming email

hi I have a bit of a problem i need help with. I have a script that runs no problems when i run it manually. as soon as i stick in tester: /app/scripts/run.pl into /etc/aliases & try to run it by sending a mail it doesnt work. the output files are owned by daemon, which i dont like & think... (7 Replies)
Discussion started by: jojo77
7 Replies

9. UNIX for Advanced & Expert Users

Problem with mailx - Can execute but email not received

Hi, I tried running mailx command like this: sadm@bioinfo-z:~$ mailx foobar@gmail.com Subject: testgmail Some content. . EOT As you can see although it is successfuly executed. But still I can't receive email at my foobar@gmail.com account. What is the cause? (9 Replies)
Discussion started by: monkfan
9 Replies

10. Forum Support Area for Unregistered Users & Account Problems

Did not received any email for account activation

hi I did not received any such email for account activation nor i am able to see any status in my profile. Am i missing anything?? :confused: Please help Appreciated. (0 Replies)
Discussion started by: bhush782003
0 Replies
Login or Register to Ask a Question