Re: [exim] Automatically processing mail to a mailbox

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Mike Cardwell
Data:  
Para: exim-users
Asunto: Re: [exim] Automatically processing mail to a mailbox
Nigel Wade wrote:

>> Hi, although I don't have a pressing need at the moment, I was thinking
>> this morning about how to send mail to an account and have a script run
>> and take an action automatically. The trigger for this was that I get a
>> mail from time to time which needs me to confirm a valid email address by
>> following an html link.
>> I would like to have this processed automatically, but I am unsure of the
>> best way to proceed. I could have a script run periodically and look at
>> the mail box designated for this and strip out the html link and follow it
>> with wget, or maybe to try and set up a pipe which mail can be delivered
>> to so a script would see the mail as input on std input.
>>
>> Are either of these a good approach or is there a better way? My methods
>> are not exim specific I think, but maybe exim can handle things directly?
>>
>>
>> Regards,
>> Andrew.
>>
>> Windows, for life without walls.
>> Linux, for life without Windows.
>
> Just use a filter. For example, I used to use this in system_filter for
> Sophos alerts/updates (when they were sent out individually):
>
> if $h_from: contains "Sophos Alert System" and
>    $h_to: contains "notification@???" and
>    $h_subject: contains "Sophos Anti-Virus IDE alert" then
>   unseen noerror pipe "/etc/exim/sophos_update"
> endif

>
> /etc/exim/sophos_update was a script which parsed the email message and
> downloaded a file from the URL contained in the message.


If you wanted to keep it entirely inside Exim, you could use "regex" in
the data acl or "mime_regex" in the mime acl to extract the url, and
then use readsocket to make the http request. A simple example of how to
do a HTTP HEAD request using readsocket:

root@haven:~# exim4 -be '${readsocket{inet:131.111.8.192:80}{HEAD /
HTTP/1.1\r\nHost: www.exim.org\r\n\r\n}}'
HTTP/1.1 200 OK
Date: Thu, 10 Dec 2009 09:56:59 GMT
Server: Apache/2.2.3 (Linux/SUSE)
Last-Modified: Sun, 01 Jul 2007 19:06:11 GMT
ETag: "6f127-4fa-4343867cacec0"
Accept-Ranges: bytes
Content-Length: 1274
Content-Type: text/html

root@haven:~#

--
Mike Cardwell - IT Consultant and LAMP developer
Cardwell IT Ltd. (UK Reg'd Company #06920226) http://cardwellit.com/
Technical Blog: https://secure.grepular.com/blog/