I am trying to get the hang of Perl and it's modules by making a simple web-based email client. I have completed the main page, and a page to retreive text email. Currently I am working on the page to send text email and have it 95% done. My problem is that it throws an error from the module I am using, specifically the open function.

<error message>
Died at C:/Perl/site/lib/Mail/Mailer.pm line 269.
</error message>

My code (taken almost verbatum from the Perl Cookbook):
my $SERVER = 'mail.domain.com'; ... sub send_text_message { # get our working variables my $to = $_[0]; my $from = $_[1]; my $subject = $_[2]; my $body = $_[3]; eval { my $mail = new Mail::Mailer ('smtp', server=>$SERVER); $mail->open({ From=>$from, To=>$to, Subject=>$subject, }) or die ("Can't send email headers: $!\n"); print $mail $body; $mail->close(); }; if($@) { print $page -> header(-type=> 'text/html', -charset=> 'utf8'), $page->p($@); return 0; } else { return 1; } }
Modules code:
sub open { my($self, $hdrs) = @_; my $exe = *$self->{Exe}; # || Carp::croak "$self->open: bad exe"; my $args = *$self->{Args}; # removed MO 20050331: destroyed the folding # _cleanup_hdrs($hdrs); my @to = $self->who_to($hdrs); $self->close; # just in case; # Fork and start a mailer (defined($exe) && open($self,"|-")) # <- line dying on || $self->exec($exe, $args, \@to) || die $!; # Set the headers $self->set_headers($hdrs); # return self (a FileHandle) ready to accept the body $self; }
I do not have a SMTP server on the localhost (I'm trying to get around that by using smtp setting). I have error handling to make sure the user is notified that the email wasn't sent. Any ideas why the open function can't send out an email?
life is a game... so have fun.

In reply to Sending out text mail by lig

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.