Rules to send mail alerts

Discuss the Scalix Server software

Moderators: ScalixSupport, admin

smjhays
Posts: 83
Joined: Thu Sep 28, 2006 2:07 pm

Rules to send mail alerts

Postby smjhays » Fri Nov 10, 2006 10:40 am

Hello,

I need to create a scalix rule that will send a text msg alert when a user receives email.

the message has to be:

"You have received a new email from *****".

I know how to do most of this the only part I can't figure out is the ***** (who to get the From: Address).

Any ideas?

Thx!

smjhays
Posts: 83
Joined: Thu Sep 28, 2006 2:07 pm

Postby smjhays » Mon Nov 13, 2006 11:56 am

I have been looking at sxaa but cannot find what I need.

Any ideas?

btisdall
Scalix Star
Scalix Star
Posts: 373
Joined: Tue Nov 22, 2005 12:13 pm
Contact:

Postby btisdall » Mon Nov 13, 2006 1:02 pm

I don't think you can do this in 'pure sxaa' - I would think along these lines:

    Create a UNIX user on your Scalix box (or another one or your network for that matter) - lets call it 'alerts'.

    Use an sxaa rule to forward mail to the 'alerts' user using the wanted criteria.

    Using procmail, pipe the messages through a script which grabs bits of the forwarded message & uses the info to mail the alert to your SMS gateway.


As far as the script itself goes, you may well not have to re-invent the wheel - try googling around 'sms gateway', 'procmail' 'script' etc.

HTH.
Last edited by btisdall on Mon Nov 13, 2006 1:03 pm, edited 1 time in total.
Ben Tisdall
www.redcircleit.com
London

jcaudell
Posts: 73
Joined: Tue Jul 18, 2006 9:56 am

Postby jcaudell » Mon Nov 13, 2006 1:03 pm

I would be curious as to how you setup the auto-txt message, if you don't mind.

btisdall
Scalix Star
Scalix Star
Posts: 373
Joined: Tue Nov 22, 2005 12:13 pm
Contact:

Postby btisdall » Mon Nov 13, 2006 1:21 pm

I'll give the script some thought.
Ben Tisdall

www.redcircleit.com

London

btisdall
Scalix Star
Scalix Star
Posts: 373
Joined: Tue Nov 22, 2005 12:13 pm
Contact:

Postby btisdall » Tue Nov 14, 2006 1:44 pm

Hi smjhays,

can you tell me what the SMS gateway expects to see in the message from Scalix in order to correctly route the SMS.
Ben Tisdall

www.redcircleit.com

London

smjhays
Posts: 83
Joined: Thu Sep 28, 2006 2:07 pm

Postby smjhays » Tue Nov 14, 2006 1:46 pm

I'm not sure. Probably just the basic headers (TO: FROM: REPLY-TO:, etc.).

btisdall
Scalix Star
Scalix Star
Posts: 373
Joined: Tue Nov 22, 2005 12:13 pm
Contact:

Postby btisdall » Tue Nov 14, 2006 2:11 pm

Can you give an example of the mail you'd need to send in order to generate the SMS.
Ben Tisdall

www.redcircleit.com

London

smjhays
Posts: 83
Joined: Thu Sep 28, 2006 2:07 pm

Postby smjhays » Tue Nov 14, 2006 2:49 pm

I was looking at the sxaa.readme and --redirect would work perfectly if we could somehow strip out the body of the message (only send the headers).

As far as the mail setup, I am not sure what you want. I can create a standard message and have it sent to the mobile phone as txt message. We have verizon and they assign us an email address (5551234567@vtext.com) that we can deliver emails to. When you send an email to this address it shows up as a txt msg on the phone. I do not know what they are looking for, but I know that it receives basic emails.

Anyone else can help us out with this one?

btisdall
Scalix Star
Scalix Star
Posts: 373
Joined: Tue Nov 22, 2005 12:13 pm
Contact:

Postby btisdall » Wed Nov 15, 2006 7:56 am

Well, out of all the possible solutions to your problem this is probably the ugliest & least production-ready - you have been warned :-)

Make sure you have the 'Email::Filter' perl module installed from CPAN or using your package manager.

Save this script as 'smsresend.pl':

Code: Select all

#!/usr/bin/perl
use strict;
use Email::Filter;
my $sms_gw_domain = "vtext.com";
my $mail = Email::Filter->new();
my $mail_from = $mail->from();
my $mail_to = $mail->to();
my $sms_addr = $mail->header("X-Original-To");
$sms_addr =~ s/(\S+\@)\S+/$1$sms_gw_domain/;
my $sendmail = "/usr/sbin/sendmail -t";
my $subject  = "New mail from $mail_from";
my $content  = "You have received a new email from $mail_from";
open(SENDMAIL, "|$sendmail") || die "Cannot open $sendmail: $!";
print SENDMAIL "To: $sms_addr\n";
print SENDMAIL "Reply-to: $mail_from\n";
print SENDMAIL "Subject: $subject\n";
print SENDMAIL "Content-type: text/plain\n\n";
print SENDMAIL "$content\n";
close(SENDMAIL);


Then create a UNIX user 'sms' and use sendmail's alias database to map each number to it, e.g.

Code: Select all

5551234567:      sms
5552234567:      sms
5553234567:      sms
# etc


Use a procmail rule on the sms account like:

Code: Select all

0:w
|/usr/local/bin/smsresend.pl 2>> /tmp/smsresend.out


To tie it all together use a --redirect --retain rule in sxaa e.g 5551234567@yourdomain.com <-- not your SMS gateway!

What the script will do is:

Extract the 'from' address from the redirected message & use this in the subject & body.
Extract the 'X-Original-To' from the redirected message & mangle this so that it becomes the correct gateway address for the user.
Send the mail.

Hope it proves at least interesting!
Ben Tisdall

www.redcircleit.com

London


Return to “Scalix Server”



Who is online

Users browsing this forum: No registered users and 3 guests