Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-28-2007, 07:28 PM   #1
LQ Newbie
Registered: Dec 2006
Posts: 24

Rep: Reputation: 15
send email using PERL

I m trying to send email using MIME lite as below

#! /usr/bin/perl -w

use MIME::Lite;
use Net::SMTP;

### Adjust sender, recipient and your SMTP mailhost
my $from_address = '';
my $to_address = '';
my $mail_host = '';

my $authUser = 'app';
my $authPass = 'app123';

### Adjust subject and body message
my $subject = 'mail testing from 129 ';
my $message_body = "Here's the attachment file(s) you wanted";

### Adjust the filenames
my $my_file_gif = 'my_file.gif';
my $your_file_gif = 'your_file.gif';
my $my_file_zip = '';
my $your_file_zip = '';

### Create the multipart container
$msg = MIME::Lite->new (
  From => $from_address,
  To => $to_address,
  Subject => $subject,
  Type =>'multipart/mixed'
) or die "Error creating multipart container: $!\n";

### Add the text message part
$msg->attach (
  Type => 'TEXT',
  Data => $message_body
) or die "Error adding the text message part: $!\n";

### Send the Message
MIME::Lite->send('smtp', $mail_host, AuthUser=>$authUser, AuthPass=>$authPass)|| die "Cannot send email\n";

But Everytime i run the script i get this error message as below
SMTP RCPT command failed:
5.0.0 <>... Use MXes or authenticate yourself

I am very sure the username and password is correct because if i telnet to my STMP hostname and send email using SMTP command it works.

any idea guys?
Old 01-29-2007, 12:14 AM   #2
LQ Guru
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 232Reputation: 232Reputation: 232
Are you sure you need to authenticate when sending? Not all SMTP hosts require this if allowed in the relay domains configuration, etc. Is you're own domain or your ISP domain?
Old 01-30-2007, 12:07 AM   #3
LQ Newbie
Registered: Dec 2006
Posts: 24

Original Poster
Rep: Reputation: 15
Yes i need to authenticate when sending

i got this one works in java program and if i use SMTP command by telneting to my STMP server port 25 i m be able to send the email successfully after authenticating myself

i m not sure how it works in PERL
Looks okay for me but it doesnt work.


Anyone has tried before or have the sample?
Old 01-31-2007, 07:11 PM   #4
LQ Newbie
Registered: Dec 2006
Posts: 24

Original Poster
Rep: Reputation: 15
any suggestion guy?

its not neccesary to use perl script as long i can send mail using script from Solaris
by specifiying the hostname and authenticate


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't send email tzpow2k2 Linux - General 3 06-29-2006 08:58 PM
email 'send' NO - email 'receive' YES..? captain skywave Linux - Wireless Networking 4 04-23-2005 03:35 AM
email 'send' YES - email 'receive' NO..? captain skywave Linux - Wireless Networking 1 04-22-2005 05:23 AM
Allowing an IP to send email using my email server... culprit Linux - Networking 7 09-09-2003 12:24 PM
sending an email to a email address after a perl operation meluser Programming 9 04-07-2003 01:26 PM

All times are GMT -5. The time now is 11:14 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration