|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
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(); ===================== |
|
#2
|
|||
|
|||
|
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); |
|
#3
|
|||
|
|||
|
Yes, there's no reason to reinvent the wheel.
|
|
#4
|
|||
|
|||
|
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); |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
>>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'; |
|
#7
|
|||
|
|||
|
Good point, but Since the e-mail was directly inserted into the script, I just used the general rule :P.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Where did the email sent (through perl) go?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|