By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,564 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,564 IT Pros & Developers. It's quick & easy.

sending an email

P: 76
Hi,
Can anyone please tell why can't send an email with the following script. I'm using mac os x (tiger)'s terminal application. Do I need to change any configuration files?

Thanks a lot in advance.


Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use MIME::Lite;
  4.  
  5. # SendTo email id
  6. my $email = "friend\@hotmail.com";
  7.  
  8. # create a new MIME Lite based email
  9. my $msg = MIME::Lite->new(
  10.         Subject => "HTML email test",
  11.         From    => "me\@somewhere.com",
  12.         To      => $email,
  13.         Type    => "text/html",
  14.         Data    => qq{<H1>Hello</H1><br>This is a test email. Please visit our site <a href="http://cyberciti.biz">online</a><hr>}
  15. );
  16.  
  17. $msg->send();
  18.  
Jan 8 '08 #1
Share this Question
Share on Google+
2 Replies


eWish
Expert 100+
P: 971
I an not sure if the OS is causing you problems or not. Read the documentation regarding Sending and see if the defaults work with your system. Also, you can add die if it won't send.
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use MIME::Lite;
  4.  
  5. # SendTo email id
  6. my $email = 'friend@hotmail.com';
  7.  
  8. my $message = qq{<H1>Hello</H1><br>This is a test email. Please visit our site <a href="http://somesite.com">online</a><hr>};
  9.  
  10. # create a new MIME Lite based email
  11. my $msg = MIME::Lite->new(
  12.           Subject => 'HTML email test',
  13.           From    => 'me@somewhere.com',
  14.           To      => $email,
  15.           Type    => 'text/html',
  16.           Data    => $message
  17. );
  18.  
  19. $msg->send() || die "Can't send email"'; 
--Kevin
Jan 9 '08 #2

KevinADC
Expert 2.5K+
P: 4,059
You need an email application to send the mail. MIME::Lite does not do that, it constructs an email, but it needs something, like sendmail, to do the actual sending.
Jan 9 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.