LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   send email using PERL (https://www.linuxquestions.org/questions/linux-newbie-8/send-email-using-perl-523630/)

just_a_kid 01-28-2007 07:28 PM

send email using PERL
 
I m trying to send email using MIME lite as below

Code:

#! /usr/bin/perl -w

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

### Adjust sender, recipient and your SMTP mailhost
my $from_address = 'am@gogo.biz';
my $to_address = 'ana@gogo.biz';
my $mail_host = 'gogo.biz';

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_file.zip';
my $your_file_zip = '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";
$msg->send_by_smtp($mail_host);


But Everytime i run the script i get this error message as below
SMTP RCPT command failed:
5.0.0 <ana@gogo.biz>... 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?

trickykid 01-29-2007 12:14 AM

Are you sure you need to authenticate when sending? Not all SMTP hosts require this if allowed in the relay domains configuration, etc. Is gogo.biz you're own domain or your ISP domain?

just_a_kid 01-30-2007 12:07 AM

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.

Thanks

Anyone has tried before or have the sample?

just_a_kid 01-31-2007 07:11 PM

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


All times are GMT -5. The time now is 03:19 PM.