Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 29th, 2000, 05:56 PM
yoshi yoshi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 108 yoshi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to yoshi
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();
=====================

Reply With Quote
  #2  
Old July 2nd, 2000, 04:06 PM
Pepe Pepe is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 71 Pepe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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);

Reply With Quote
  #3  
Old July 7th, 2000, 10:21 AM
ledjon
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Yes, there's no reason to reinvent the wheel.

Reply With Quote
  #4  
Old July 8th, 2000, 05:00 PM
yoshi yoshi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 108 yoshi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to yoshi
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);

Reply With Quote
  #5  
Old July 8th, 2000, 06:12 PM
ledjon
Guest
Dev Shed Newbie (0 - 499 posts)
 
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.

Reply With Quote
  #6  
Old July 9th, 2000, 12:26 PM
freebsd
Guest
Dev Shed Newbie (0 - 499 posts)
 
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';

Reply With Quote
  #7  
Old July 9th, 2000, 01:45 PM
ledjon
Guest
Dev Shed Newbie (0 - 499 posts)
 
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Where did the email sent (through perl) go??

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap