Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^4: forwarding emails with perl??

by bfdi533 (Friar)
on Sep 20, 2006 at 21:02 UTC ( #574004=note: print w/replies, xml ) Need Help??

in reply to Re^3: forwarding emails with perl??
in thread forwarding emails with perl??

Righto. Here is my stab at this:
use strict; use warnings; use Email::Send; use Email::Simple; my %received; my @email; #my $box = Email::Folder->new('/home/jonathan/mail/Recruiters/'); @email = <>; my $message = join "\n", @email; my $mail = Email::Simple->new($message); $mail->header_set('To',''); my $sender = Email::Send->new({mailer => 'SMTP'}); #my $sender = Email::Send->new({mailer => 'Sendmail'}); $sender->mailer_args([Host => 'localhost']); my $rv = $sender->send ($mail->as_string()); use Data::Dumper; print Dumper($rv); my @available = $sender->all_mailers; print Dumper(@available);

Unfortunately, though it sppears to be proper code and all, it produces the following error:

$VAR1 = bless( { 'prop' => {}, 'string' => 'Can\'t call method "address" on an undef +ined value at /usr/lib/perl5/vendor_perl/5.8.8/Email/Send/ lin +e 56, <> line 68. ', 'type' => 'failure', 'errno' => 1 }, 'Return::Value' );

Anyone have any idea what is wrong here?

Replies are listed 'Best First'.
Re^5: forwarding emails with perl??
by gellyfish (Monsignor) on Sep 20, 2006 at 21:30 UTC

    I can't be bothered to test at the moment but I think your problem is the

    @email = <>; my $message = join "\n", @email;
    where you could possibly better off doing something like
    my $message = do { local $/; <> };
    But the join you have is unnecessary as you haven't removed the line endings. A
    my $message = join '', @email;
    would be sufficient in your code.


      The my $message = join '', @email; worked perfectly. Thanks.

      Now I have other issues about relay being denied because I am trying to keep the originator email address (from header) in place so as to make it a bounce and I cannot relay for addresses outside of my domain. But, that is a problem that I need to fix locally somehow, I guess.

      Still, if there were a better way to do this without having to open relay up ...

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://574004]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (1)
As of 2023-03-29 19:55 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (72 votes). Check out past polls.