The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Perl Programming
|
Where did the email sent (through perl) go??
Discuss Where did the email sent (through perl) go?? in the Perl Programming forum on Dev Shed. Where did the email sent (through perl) go?? Perl Programming forum discussing coding in Perl, utilizing Perl modules, and other Perl-related topics. Perl, the Practical Extraction and Reporting Language, is the choice for many for parsing textual information.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 29th, 2000, 05:56 PM
|
|
Contributing User
|
|
Join Date: Jan 2000
Posts: 108
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
Hello.
I am trying to write a simple perl script that sends an email to someone. When I run it, it seems to work correctly (getting to the blank screen), but I never get the email. How long should I wait for the email (I have included the script below)?
Thanks
yoshi
datera@datera.com http://www.datera.com
=====================
#!/usr/local/bin/perl -w
print "Content-Type: text/htmlnn";
use Net::SMTP;
my $subject = "Subject: My test messagenn";
my $message = <<EOM;
Perl sent this message. Nifty, Eh?
EOM
$smtp = Net::SMTP->new('mailhost');
$smtp->mail($ENV{USER});
$smtp->to('datera@datera.com');
$smtp->data();
$smtp->datasend($subject);
$smtp->datasend($message);
$smtp->dataend();
$smtp->quit();
=====================
|

July 2nd, 2000, 04:06 PM
|
|
Contributing User
|
|
Join Date: Jun 2000
Posts: 71
Time spent in forums: < 1 sec
Reputation Power: 13
|
|
|
you don't need to use Net::SMTP for sending email. It is very simple from perl directly:
# Path to your mail program
$mailprogram = '/usr/lib/sendmail';
open (MAIL, "|$mailprogram -t");
print MAIL "To: $FORM{'email'}n";
print MAIL "From: yosh@your.comn";
print MAIL "Subject: Testingnn";
print MAIL "Hello world<BR>";
print MAIL "just testingn";
# and next command sends email
close (MAIL);
|

July 7th, 2000, 10:21 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
Yes, there's no reason to reinvent the wheel.
|

July 8th, 2000, 05:00 PM
|
|
Contributing User
|
|
Join Date: Jan 2000
Posts: 108
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
Thanks... but why won't this work?
I do not have the capabilities to see the logfile, or run it with the command-line (I have a Mac). How could I work this so it works for the web?
Thanks!
yoshi
datera@datera.com
========================
#!/usr/local/bin/perl -w
print "Content-Type: text/htmlnn";
$mailprogram = '/usr/local/bin/sendmail';
open (MAIL, "|$mailprogram -t");
print MAIL "To: datera@datera.comn";
print MAIL "From: yosh@your.comn";
print MAIL "Subject: Testingnn";
print MAIL "Hello world<BR>";
print MAIL "just testingn";
close (MAIL);
|

July 8th, 2000, 06:12 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
Here are 2 very important, basic rules that everybody should remember and will fix your script.
1. All "@"'s that are not signifying and array should be "@".
2. Always make sure the paths are right. I don't know if this effects your script, it varies from system to system. But the path to sendmail was wrong for my system.
Here is the fixed code (with my path to sendmail):
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
#!/usr/local/bin/perl -w
print "Content-Type: text/htmlnn";
$mailprogram = '/usr/sbin/sendmail';
open (MAIL, "|$mailprogram -t");
print MAIL "To: datera@datera.comn";
print MAIL "From: yosh@your.comn";
print MAIL "Subject: Testingnn";
print MAIL "Hello world<BR>";
print MAIL "just testingn";
close (MAIL);
[/code]
Let us know if it does/doesn't work.
|

July 9th, 2000, 12:26 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
>>1. All "@"'s that are not signifying and array should be "@".
Yes.
Yoshi,
If you define $admin_email like with double-quotes, you need to escape the @ character..
$admin_email = "datera@datera.com";
with single-quotes, that is not necessary, however.
$admin_email = 'datera@datera.com';
|

July 9th, 2000, 01:45 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
Good point, but Since the e-mail was directly inserted into the script, I just used the general rule :P.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|