[jdev] jabberSMTP

Jon Scottorn jscottorn at possibilityforge.com
Thu Dec 15 14:41:28 CST 2005


Still get same error

here is what shows up in jabber

[01:40:20 PM] *** jabbermail is Online [forwarding email]
[01:40:20 PM] *** jabbermail is Offline

Don't know if that helps

On Thu, 2005-12-15 at 22:37 +0200, Norman Rasmussen wrote:

> odd, with that error I wouldn't expect it to be sending the jabber messages.
> 
> try adding:
> 
>     my $jabmsg = Net::Jabber::Message->new();
> 
> just before:
> 
>     # Compose the message
> 
> On 12/15/05, Jon Scottorn <jscottorn at possibilityforge.com> wrote:
> >            Ok, disregard all my previous emails, I have got it sending to jabber now but there is something else wrong now that I have no clue how to fix.  I send the message and it sends to my jabber client saying [forwarding message] and that's it.  I also get a reply back in my email with this error.
> >
> >  Can't call method "SetMessage" on an undefined value at smtp2jabber.pl line 42, <STDIN> line 1.
> >  554 5.3.0 unknown mailer error 255
> >
> >  Anyone know what that is.
> >
> >  I am sending my email message as plain text with no attachments.
> >
> >  Thanks,
> >
> >  Jon
> >
> >  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/

Jon Scottorn
Systems Administrator
The Possibility Forge, Inc.
http://www.possibilityforge.com
435.635.0591 x.1004
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.jabber.org/jdev/attachments/20051215/5c5a9b4d/attachment-0002.htm>


More information about the JDev mailing list