Linux - NewbieThis 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!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to create a perl function for sending mail, I have successfully installed the perl module Net::SMTP .
When I run the below script but got the below errors , would advise what is wrong in my case ? thanks
Code:
my script
============
#!/usr/bin/perl
use warnings;
use strict;
use Net::SMTP;
my $smtpserver = 'localhost';
my $smtpport = 25;
my $smtpuser = 'user';
my $smtppassword = 'password';
my $smtp = Net::SMTP->new($smtpserver, Port=>$smtpport, Timeout => 10, Debug => 1);
die "Could not connect to server!\n" unless $smtp;
$smtp->auth($smtpuser, $smtppassword);
$smtp->to('jpdees@gmail.com');
$smtp->data();
$smtp->datasend("To: mymail\@gmail.com\n");
$smtp->quit;
Code:
run script error
================
Net::SMTP>>> Net::SMTP(2.33)
Net::SMTP>>> Net::Cmd(2.30)
Net::SMTP>>> Exporter(5.58)
Net::SMTP>>> IO::Socket::INET(1.29)
Net::SMTP>>> IO::Socket(1.29)
Net::SMTP>>> IO::Handle(1.25)
Net::SMTP=GLOB(0x10398490)<<< 220 localhost.localdomain ESMTP Sendmail ; Mon, 28 Apr 2014 17:16:22 +0800
Net::SMTP=GLOB(0x10398490)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x10398490)<<< 250-localhost.localdomain Hello localhost.localdomain [127.0.0.1], pleased to meet you
Net::SMTP=GLOB(0x10398490)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x10398490)<<< 250-PIPELINING
Net::SMTP=GLOB(0x10398490)<<< 250-8BITMIME
Net::SMTP=GLOB(0x10398490)<<< 250-SIZE 20000000
Net::SMTP=GLOB(0x10398490)<<< 250-DSN
Net::SMTP=GLOB(0x10398490)<<< 250-ETRN
Net::SMTP=GLOB(0x10398490)<<< 250-DELIVERBY
Net::SMTP=GLOB(0x10398490)<<< 250 HELP
Net::SMTP=GLOB(0x10398490)>>> RCPT TO:<jpdees@gmail.com>
Net::SMTP=GLOB(0x10398490)<<< 503 5.0.0 Need MAIL before RCPT
Net::SMTP=GLOB(0x10398490)>>> DATA
Net::SMTP=GLOB(0x10398490)<<< 503 5.0.0 Need MAIL command
Net::SMTP=GLOB(0x10398490)>>> To: mymail@gmail.com
Net::SMTP=GLOB(0x10398490)>>> .
Net::SMTP=GLOB(0x10398490)<<< 500 5.5.1 Command unrecognized: "To: mymail@gmail.com"
Net::SMTP=GLOB(0x10398490)>>> QUIT
Net::SMTP=GLOB(0x10398490)<<< 500 5.5.1 Command unrecognized: "."
Code:
maillog error
==============
s3S9GMHo009143: localhost.localdomain [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN during connection to MTA
Last edited by byran cheung; 04-28-2014 at 04:20 AM.
I just check the maillog and found that the mail is relay to another smtp server , not relay to localhost ( relay=[127.0.0.1] ) , I found that the mail sent from this server was use localhost relay , but this perl script relay another smtp server , would advise what is the problem ? thanks
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.