lig has asked for the wisdom of the Perl Monks concerning the following question:
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>Modules code: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; } }
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?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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sending out text mail
by gube (Parson) on Oct 17, 2005 at 06:47 UTC | |
|
Re: Sending out text mail
by tirwhan (Abbot) on Oct 17, 2005 at 09:24 UTC | |
|
Re: Sending out text mail
by Delusional (Beadle) on Oct 17, 2005 at 09:13 UTC | |
|
Re: Sending out text mail
by pajout (Curate) on Oct 17, 2005 at 09:28 UTC | |
|
Re: Sending out text mail
by terra incognita (Pilgrim) on Oct 17, 2005 at 22:54 UTC |