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