Dear Monks,
I'm putting together a form to mail some data to one of users and am using Net::SMTP to mail them. However I keep coming across an error message whilst testing saying that I have an undefined value in
$smtp->mail( $from ); but I'm sure I have defined this further up the form. I would be grateful if somebody could point out what I have missed as this is the first time I've used this module and I'd like to leanr how to make it work properly.
Many thanks.
#! c:\perl\bin\perl.exe
use strict;
use warnings;
use cgi;
use Net::SMTP;
#constants
my $mailserver_url = "foo.bar.baz";
my $to = "foo\@bar";
my $from = "bar\@foo";
my $subject = "Mail time";
my $smtp = Net::SMTP->new('$mailserver_url');
#Sending the message
$smtp->mail( $from );
$smtp->to( $to );
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n"); # done with header
$smtp->datasend($name, $company, $country, $email);
$smtp->dataend();
$smtp->quit(); # all done. message sent.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.