Re: Basic script to send mail details!



On Sun, Jun 22, 2008 at 9:38 AM, Gunnar Hjalmarsson <noreply@xxxxxxxxx> wrote:
Francisco Valladolid wrote:

I'm writting a basic Perl script to send mail using the Mail::Send
module for it via CGI.pm

I have:

...
use CGI qw/:standard/;

print header,
start_html('Sending ...'):

$mail_to = param('email');

$msg = Mail::Send->new;

You can skip that line.

$msg = Mail::Send->new(Subject=>Some Subject', To=>$mail_to);
$msg->cc('some@xxxxxxxxxx');

... bla bla

Whenever, the script don't send the mail to the param get from the
email field in the form.

Are you sure that $mail_to was populated in accordance with your
expectations? What if you simply print it?

Yes, .. I'm doing the initial tests and email variable in the form
contain a valid email (user@host)


Is correct interpolate the variable $mail_to or need put single quotes
o maybe double quotes?

You don't need any quotes around $mail_to.

Thanks.

Maybe you should post a _short_ but _complete_ script that illustrates the
issue. If you do, please copy and paste; don't retype. Enable strictures and
warnings, capture possible errors and let us know about the messages in the
error log.


This is the script:

#!/usr/bin/perl -w
use strict;
use CGI qw/:standard/;

require Mail::Send;

my ($msg, $fh, $body, $mail_to);

my $body =<<HTML;
bla bla bla
HTML

print header,
start_html('Confirmacion:');

# param via Cgi.pm
$mail_to = param('email');

$msg = Mail::Send->new;
$msg = Mail::Send->new(Subject=>'subject');
$msg->to($mail_to);
$msg->cc('info@xxxxxxxxxxxxxxxxxxxxxxxxxx');

$fh = $msg->open; # some default mailer

print $fh "$body";

$fh->close; # complete the message and send it

print end_html;





--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/






--
Francisco Valladolid H.
-- http://bsdguy.net - Jesus Christ follower.
.



Relevant Pages

  • Re: Basic script to send mail details!
    ... bla bla ... Maybe you should post a _short_ but _complete_ script that illustrates the issue. ... capture possible errors and let us know about the messages in the error log. ...
    (perl.beginners)
  • Re: perl and gnuplot
    ... # an html form (the form is also generatedby this script) ... print header; ...
    (perl.beginners)
  • Re: Init script not called during system shutdown
    ... Try to modify the start and stop script as follows. ... # Startup script for Oracle AS 10g R2 ... # description: Bla bla bla ... and I'd like to setup a startup/shutdown script to manage an Oracle AS ...
    (RedHat)
  • getopt
    ... create a script which I can pass switches as arguments. ... script will replace the rm command on my linux server, ... print STDERR <<EOF; ... bla bla bla ...
    (perl.beginners)
  • Re: Init script not called during system shutdown
    ... mark wrote: ... The only particularity of the script is that the ... # description: Bla bla bla ... wall "Stopping ora-as1" ...
    (RedHat)