[jdev] jabberSMTP

Norman Rasmussen norman at rasmussen.co.za
Thu Dec 15 14:14:52 CST 2005


see:

http://www.debian-administration.org/articles/140
http://koivi.com/exim4-config/

both articles explain how to set up the virtual domains config for
Debian and exim4.

You can probably short circuit the double config change and put the
following in /etc/mail/virtual/your.jabber.org:
*:      |smtp2jabber.pl

However this is untested, and I'm not quite sure if it would work
'out-of-the-box'.

On 12/15/05, Jon Scottorn <jscottorn at possibilityforge.com> wrote:
>            Ok, I setup everything up and added the virtusertable, not sure if that's what I was supposed to do, but it is not sending to the jabber user.  it is going to each specific user under /var/spool/mail.  If you could let me know what I am doing wrong I would appreciate it.
>
>  Thanks
>
>  On Thu, 2005-12-15 at 06:22 -0500, Bart Smit wrote:
>
>  Assuming that on the jabber server your MTA is sendmail you can do this:
>
> Edit your sendmail.cf to listen for external connections:
> dnl #  DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
>
> Set a catch all for the server or domain in /etc/mail/virtusertable:
> @your.jabber.org		mailerscript
>
> Add an alias for the script in /etc/aliases (don't forget to run
> newaliases as root):
> mailerscript	|smtp2jabber.pl
>
> Manually register a bot user on your jabber server and set the user/pass
> to mailer/password (if you use other credentials, edit the script
> accordingly).
> Save the attached script as smtp2jabber.pl and place it in /etc/smrsh or
> link it from there. Remember to chmod it to be world executable.
>
> Use cpan or your favourite package manager to install the perl modules
> at the top of the script. Restart sendmail and test.
>
>
> Bart...
>
>
>
> #!/usr/bin/perl
>
> use strict;
> use Mail::Message;
> use Mail::Message::Field;
> use Mail::Message::Construct::Read;
> use Mail::Message::Attachment::Stripper;
> use Mail::Message::Body;
> use Net::Jabber;
>
> use constant SERVER   => "your.jabber.org";
> use constant PORT     => 5222;
> use constant USERNAME => "mailer";
> use constant PASSWORD => "password";
> use constant RESOURCE => "Perl Script";
>
>
> # The email message come in on STDIN
> my $msg = Mail::Message->read(\*STDIN);
>
> # Pick out the recipient, subject and sender
> my $rcpt    = $msg->head->get('to');
> my $subject = $msg->head->get('subject');
> my $sender  = $msg->head->get('from');
>
> # Remove the angle brackets
> $rcpt =~ s/^<//;
> $rcpt =~ s/>$//;
> $sender =~ s/^<//;
> $sender =~ s/>$//;
>
> # Remove the attachment(s) from the message
> my $stripper = Mail::Message::Attachment::Stripper->new($msg);
> my Mail::Message $textonly  = $stripper->message;
> my $body = $textonly->body;
>
> # Connect to jabber
> my $jabber = &setup_Jabber(SERVER, PORT, USERNAME, PASSWORD, RESOURCE,
> "normal/forwarding email");
>
> # Compose the message
> my $jabmsg->SetMessage(
>               "to"      => "$rcpt",
>               "subject" => "$sender emailed: $subject",
>               "body"    => "$body");
>
> # And send it
> $jabber->Send($jabmsg);
>
> # Close the connection and exit
> $jabber->Disconnect();
> exit(0);
>
>
> sub setup_Jabber {
>   my ($server, $port, $user, $pass, $resource, $initial_status) = @_;
>   my $connection = new Net::Jabber::Client;
>
>   # Connect
>   my $status = $connection->Connect( hostname => $server,
>                                      port     => $port );
>   die "Cannot connect to Jabber server $server on port $port\n"
>     unless $status;
>
>   # Callbacks
>   $connection->SetCallBacks( presence => \&InPresence );
>
>   # Ident/Auth
>   my @result = $connection->AuthSend( username => $user,
>                                       password => $pass,
>                                       resource => $resource );
>   die "Ident/Auth failed: $result[0] - $result[1]\n"
>     if $result[0] ne "ok";
>
>   # Roster
>   $connection->RosterGet();
>
>   # Set initial presence
>   &set_presence($connection, $initial_status);
>
>   return $connection;
> }
>
> sub InPresence
> {
>   my $presence = $_[1];
>   my $type = $presence->GetType();
>
>   if ($type eq "subscribe") {
>     $jabber->Send($presence->Reply(type => 'subscribed'));
>   }
>   elsif ($type eq "unsubscribe") {
>     $jabber->Send($presence->Reply(type => 'unsubscribed'));
>   }
> }
>
> sub set_presence {
>   my ($connection, $s) = @_;
>   my $presence = Net::Jabber::Presence->new();
>   my ($show, $status) = split("/", $s, 2);
>   $presence->SetPresence( show   => $show,
>                           status => $status );
>   $connection->Send($presence);
> }
>
> -----Original Message-----
> From: jdev-bounces at jabber.org [mailto:jdev-bounces at jabber.org] On Behalf
> Of Peter Saint-Andre
> Sent: 14 December 2005 23:53
> To: Jabber software development list
> Subject: Re: [jdev] jabberSMTP
>
> Jon Scottorn wrote:
> > Hi all,
> >
> >    I have been trying to locate a jabber smtp transport, does anyone
> > know of any such thing.  I basically need something that will parse an
>
> > email sent to say jonsmel at jabber.org <mailto:jonsmel at jabber.org> and
> > reformat it into a xmpp message and send it to the user.  I don't
> > really care about attachments, it will only be text.
> >
> > Does anyone know of this type of item?
>
> The old theoretic-smtp project did something like that, but it
> disappeared after the JabberStudio rootkit. I've sent the code to Jon on
> an as-is basis. If anyone else has code like this (more recent than
> theoretic-smtp), feel free to post to the list. :-)
>
> Peter
>
>
>
>
>   Jon Scottorn
>  Systems Administrator
>  The Possibility Forge, Inc.
>  http://www.possibilityforge.com
>  435.635.0591 x.1004



--
- Norman Rasmussen
 - Email: norman at rasmussen.co.za
 - Home page: http://norman.rasmussen.co.za/



More information about the JDev mailing list