Send mail question

A

Antony

Hi,

I found this perl script on a website regarding sending emails.

#!/usr/bin/perl
use CGI;

my $query = new CGI;
my $sendmail = "/usr/sbin/sendmail -t";
my $reply_to = "Reply-to: (e-mail address removed)";
my $subject = "Subject: Confirmation of your submission";
my $content = "Thanks for your submission.";
my $to = (e-mail address removed);

runmeail {
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
print SENDMAIL $reply_to;
print SENDMAIL $subject;
print SENDMAIL $to;
print SENDMAIL "Content-type: text/plain\n\n";
print SENDMAIL $content;
close(SENDMAIL);
}

print $query->header;
print "Confirmation of your submission will be emailed to you.";


However when I go and run the script from the browser, I don't recieve any
emails. Is this because the script must be posted too, or have I simply
missed something out? My aim is to incorporate it into a larger script which
processes an email automatically, however this part is obviously not
working.

thanks

Antony
www.cdtoday.co.uk
 
T

Tad McClellan

Antony said:
I found this perl script on a website regarding sending emails.


It is worth *less* than what you paid for it.

my $reply_to = "Reply-to: (e-mail address removed)";


There is a bug there that warnings would have found.

my $to = (e-mail address removed);


There is a bug there too.

runmeail {


Looks like another bug, where is the "sub" keyword?

Is "runemail" misspelled there?

Is this the actual code or did you re-type it?

print $query->header;
print "Confirmation of your submission will be emailed to you.";


It says that it will output HTML but then it does not output HTML.

However when I go and run the script from the browser, I don't recieve any
emails.


1) Contact the author of the script for support
or
2) Learn Perl programming
or
3) Hire someone who already knows Perl programming to write
a useable version for you

Is this because the script must be posted too,


What does "posted" mean?

processes an email automatically,


There is a Frequently Asked Question about mail:

perldoc -q mail

How do I send mail?
 
A

Alan Mead

Star date: Sat, 22 Jan 2005 23:01:51 +0000, Antony's log:
I found this perl script on a website regarding sending emails.
[snip]
However when I go and run the script from the browser, I don't recieve any
emails. Is this because the script must be posted too, or have I simply
missed something out? My aim is to incorporate it into a larger script which
processes an email automatically, however this part is obviously not
working.

I don't know what "run the script from the browser" means. Tad points out
numerous problems. You definitely have to have the script installed on
the server, you need to ensure that the script can find sendmail using the
path in the script, etc.

You need to be clearer about what precisely is happening. Is email being
generated but then lost/misdirected/caught by spam? How do you know? Are
you running this on a Unix-ish or a Windows server? I've found that
sending email can be tricky for reasons that have nothing to do with Perl.

FWIW, my favorite package for doing this is MIME-Lite which makes it very
easy to send email directly or using SMTP. The MIME-Lite documentation is
concise and informative.

-Alan
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top