How do I have mails to a specific address trigger actions on a web server? - apache

What I'm trying to do is figure up how I can configure a mail server such that mails to a specific address will trigger certain actions- e.g. inserting the subject line into a MySQL database, etc. This is for a web app in LAMP- basically I want people to be able to add things automatically via email if they'd rather do that than use the web interface. Kind of like how e.g. with Evernote you can send a mail to your custom address to add a note that way.
I realize this is a pretty vague question, what I'm looking for is a general place to start looking and learning. I'm reasonably familiar with website tech but when it comes to mail servers I'm completely clueless. I'm not looking for any specific implementation: Rather I just want to know what are the basics I need familiarize myself to be able to attack the problem.

If you want to trigger actions "in realtime" you best work with your own mailserver and use something like procmail: Here is an example from the procmail faq how to trigger actions on incoming mails: http://porkmail.org/era/procmail/mini-faq.html#rtfm
But if you can avoid this, just let the fun stuff of mailserver work handle your provider and scan one or more mailboxes via cron-job (on linux/unix) triggered scripts. A cronjob could e.g. be a command line PHP script or a wget script that does a HTTP request on your webserver script to start the action. Your script reads the actual mails via something like http://pear.php.net/manual/en/package.networking.net-pop3.php
(Try to avoid importing the same mail twice e.g. by relying on the message id of the mail or by creating SHA1/MD5 hashes on parts or the body of the mail).
A lot of ticket systems work like this (for example OTRS: http://otrs.org/downloads).

This is traditionally handled on unix-like systems using fetchmail and/or procmail.

Related

How do you access a Marketo Token in Velocity script

I'm creating an email in Marketo that is sent when a new article is posted on my website and contains a section at the bottom for a related article as well. The article and related article information are set up automatically using tokens (they are triggered via an API call).
I want to hide the related article section if there is no related article present. This seems like something that should be done via a Script token. However, I can't figure out how to access token data (e.g. {{my.related_post_headline}}) from within my script token. Is this possible? If not, what is the best practice for having dynamic content based on token data?
At this time it is not possible to read Program Tokens using Marketo's Velocity Scripting. You can read data from Lead fields and from Custom Objects.
Keep in mind that Velocity Scripting is relatively slow, so it may delay your email send for large volumes (it has to execute the script for each email). You can use Head Start if you're using an Email Program, which will pre-process the Velocity Script.
Alternatively, you could choose NOT to use Velocity Scripting and insert Lead Tokens or Program Tokens directly into the email. This will speed up email rendering.

What is preventing people from using someone else's CAPTCHA as their own?

Why (other than moral reasons) don't more people use the CAPTCHAs of other sites as their own while selling the solving of said CAPTCHAs?
To me, such a system seems like it would be simple to implement:
set up a script that does something on another website that requires a CAPTCHA to be completed through the use of a proxy service
when a user on your site performs a task that requires the completion of a CAPTCHA, simply serve them the CAPTCHA that the other
site asks you to solve
when the user solves the CAPTCHA, your script can perform the desired action on the other site that is the source of the CAPTCHA,
and the user on your site is also verified through this process
Is this commonplace? If not, why not? What, if anything, could be done to prevent this?
Fetching the captcha. Assuming one could easily fetch the exact visual of the captcha from the foreign host. To do this, you have to pass the referral check (most browsers (navigated by humans) allow to send the http_referer). You also would have to save the session_id and the secret from the hidden input.
Checking the result. The foreign host must link the saved variables with the ones associated with the session of your first request, which requires you to implement tricky cURL methods. You would have to handle multiple parallel requests, all from your single ip.
Your server will probably use more resources when hacking a captcha on a foreign host than if it generates a captcha on its own.
Prevents
http_referer check
limit requests for single IP to e.g. 5 / minute
good session handling and tricky cookies
it's not impossible to reverse engineer javascript, but the more complicated your javascript is, ...
you have to find a pattern that recognizes the result on the foreign host. the easiest signature may be the Location header field, leading either to /path/success.html or /path/tryagain.php
Challenge:
I took a moment to prepare an example: http://woisteinebank.de/test/
In this example, I attach keys to the session_id(); and save it in the database.
Through session_regenerate_id(); I have a fresh session on every request.
In check.php, I compare the database values to the $_GET values.
Try to find a way to get leech this captcha, I'll try to defend. Everytime you sucessfully use my captcha on your site, I try to defend it.

How to modify the default receiver list in system Mail app

I'm using Objective-C. I wonder is there any plug-ins or libraries that can allow me to modify the default receiver list in system Mail app?
For example, I have made an app which can scan a card and fetch the E-mail information on it.
Now, I'd like to put the E-mail data I've fetched into system Mail app's receiver list. That is, when I use the system Mail app and write a new mail, I can see the E-mail address I fetched when I type some letters in the receiver column.
Is that possible to achieve?
This list is stored as a Sqlite database and it should be possible to append to it from another process, even while Mail.app is running. I haven't tested it, though.
The following article should help. It describes how to delete entries but adding new ones would work in pretty much the same way: http://hints.macworld.com/article.php?story=20110516152604993

What is the fastest way to determine if a given email is valid via command line?

I want to automate the validation of a significant number of emails.
My first thought was to run telnet and query the Google SMTP server with each email, but then I would have to parse the output which adds an extra step to the process, which, given the quantity of tests to be run, would make the process infinitely slower.
So, my question is, what is the most computationally inexpensive way to test emails for validity in bulk.
Connecting to the Google mail exchanger would allow to validate just the email addresses handled by Google itself. On top of that, parsing an SMTP dialog is not an easy thing, provided you need to handle every possible SMTP status code. Furthermore, validating lots of email addresses in this way would make Google ban your IP address(es) if you overload its mail exchangers.
That being said and assuming you are running under Windows, if you need to validate your lists of email addresses from the command line I would suggest using our email validation library coupled with a simple PowerShell script. Our software supports PowerShell by way of the custom Verify-EmailAddress cmdlet or, for advanced scenarios, by way of a handful set of .NET classes which can be easily used from within PowerShell and it can perform advanced syntax check, DNS validations, mailbox existence test and much more.
Here is a short sample showing how to validate a list of email addresses using the built-in Verify-EmailAddress cmdlet:
'me#example.com', 'you#example.com' |
? { (Verify-EmailAddress $_ -Level MailBox).IsSuccess }
Finally, if you are familiar with C# please take a look at these code samples, that you may easily convert to PowerShell (just ask us for help).

From email to shared hosted backend to remote frontend

So my friend hosts a little get together every once in a while where space is limited to the first 14 people who RSVP. He emails the invite out to a list and then accepts the first people who respond. Tonight I barely got in because I can't always check my email, so I told him that I would write a program that would respond instantly to his request. This would not normally be a problem (autoresponder, easy) except he has recently created an online signup form. I think it would be funny for him to send out his next invite and get a sub-100ms response from me, so I would like to give this a try.
The problem is, I'm not quite sure how to go about it without going to to much expense. I have a personal site that can host some .NET backend code, but it's on a shared GoDaddy server so I don't really have a ton of access to the mailserver or anything. I was thinking that if I could get an email sent to a certain address that maybe it could trigger a webrequest that could pull down his page and then fill the (very simple, like 2 or 3 inputs) form out and submit it, but again, I'm not quite sure how.
Would anyone have an idea about how I could go about this? I would want for this to happen automatically without any sort of interaction from me, just basically as soon as I get an email from a certain email address, somehow my code is triggered and the form filled out and submitted.
This is just for fun, but the programmer in me is curious as to how I could actually get this to work.
Thanks!
The most affordable thing I know of would be through NearlyFreeSpeech.NET. If you set up an account there, you can configure a domain with email forwarding for 3 cents/day. They have an option to forward the email to a script, so you could write something that would look at the mail, pull down the form, and post to a server.
I'm not sure but I think the script has to be running on their servers, so you'll have to set up a website (another few cents per day) and write the script to run in a UNIX environment (PHP or Perl or such). If you insist on .NET, you could write a minimal PHP script to forward the data to your GoDaddy account.