sending email thru perl script


D

dawnofdigital

Hi, I'm new to cgi/perl and I'm wondering how to send an email through
a perl program to a future user on my site. I've been experimenting and
so far I've gotten the following, but it doesnt seem to be working. Can
anyone point me in the right direction with this little script?

#!/usr/local/bin/perl -w
use CGI;
$cgi = new CGI();
print $cgi->header();
use Net::SMTP;
my $adress = "dawnofdi\@dawnofdigital.net";
my $smtp = Net::SMTP->new('localhost');
$smtp->mail("dawnofdi\@dawnofdigital.net");
$smtp->to("dawnofdigital\@gmail.com");
$smtp->data();
$smtp->datasend("From: dawnofdi\@dawnofdigital.net\n");
$smtp->datasend("To: dawnofdigital\@gmail.com\n");
$smtp->datasend("Subject: Email Script Test\n");
$smtp->datasend("\n");
$smtp->datasend("If you are reading this, then emailsend.cgi works!");
$smtp->dataend();
$smtp->quit();
print "successfully sent to dawnofdigital\@gmail.com";
 
Ad

Advertisements

K

Keith Keller

Hi, I'm new to cgi/perl and I'm wondering how to send an email through
a perl program to a future user on my site. I've been experimenting and
so far I've gotten the following, but it doesnt seem to be working.

Define "it doesn't seem to be working"! Be specific. What do
you want to see (that might seem obvious, but make it explicit),
what do you do to run the script, and what happens?
#!/usr/local/bin/perl -w

use strict;
use warnings;
use CGI;
$cgi = new CGI();
print $cgi->header();
use Net::SMTP;
my $adress = "dawnofdi\@dawnofdigital.net";

You define this variable, but don't use it.
my $smtp = Net::SMTP->new('localhost');

You should check the return value, and emit a message if new
doesn't connect.

As for the rest, without you describing how your script is failing,
anyone would be hard-pressed to make any recommendations.

--keith
 
U

usenet


This question has been multi-posted (to PB). Multiposting is the usenet
mortal sin.

I presume the OP is not a rude person and doesn't understand why
multiposting is so rude. The OP may therefore wish to review the
posting guilelines for this newsgroup (http://tinyurl.com/pjzmm) where
this is explained.

The OP should realize that repeated infractions (especially
multiposting) will get him/her killfiled, especially in this particular
newsgroup.

I suggest this thread be burned.
 
U

usenet

multiposting is so rude. The OP may therefore wish to review the
posting guilelines for this newsgroup (http://tinyurl.com/pjzmm) where
this is explained.

You know what - I don't actually think this IS explained in the CLPMisc
guidelines. So permit me to add my own explanation:

WHAT IS CROSS-POSTING?
Cross-posting is when the same message is posted to multiple
newsgroups, but it is possible for group participants to discern (by
the message header) that the message has been cross-posted. This is
usually considered poor usenet ettiquete. Also, some usenet clients
(esp. GoogleGroups) "reply to all" by default, so if a responder does
not notice that the message is cross-posted, s/he may send a response
to multiple groups when this was not the intent.

WHAT IS MULTI-POSTING?
Multi-posting is when the same message is posted to multiple
newsgroups, but this fact cannot be determined by the message headers.
Therefore, someone reading the thread has no way to know that the same
message is posted elsewhere (unless s/he happens to visit the other
newsgroup).

WHY IS MULTI-POSTING SO RUDE?
Because when you ask a question in multiple groups (without telling
anybody), it is possible and likely that kind and helpful people will
take the time and effort to respond to the question even though it may
have ALREADY BEEN ANSWERED elsewhere. This wastes the time of the kind
responder. It is rude to waste the time of folks who only want to be
helpful.

WHEN/HOW IS MULTIPOSTING ACCEPTABLE?
If you wish to later post the same question in another newsgroup
(for whatever reason), you should make it known in your new post where
the question is already posted (and maybe furnish a link), and you
should respond to your original message with the information about
where the question is now also posted (and maybe furnish a link). This
lets folks in both newsgroups know that the question is posted
elsewhere, and gives them the opportunity to investigate other
responses before taking the time and effort to respond themselves.

When I encounter a "stealth" multipost (usually between CLPMisc and PB)
I always alert both communities and suggest the thread be burned.
 
Ad

Advertisements

D

Dr.Ruud

(e-mail address removed) schreef:
WHAT IS MULTI-POSTING?
Multi-posting is when the same message is posted to multiple
newsgroups, but this fact cannot be determined by the message headers.

With multi-posting it is technically not the same message, but a new
independent message per group. Each message has its own Message-ID.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top