sendmail never send mail. Always deffered - linux

I'm working on a debian squeeze domU ( xen virtualized ) called webserv (result of hostname) and want to send mail using sendmail.
The user name of the user logged in the box is: username
I changed the hostname to a FQDN (mydomain.com).
I go with the default sendmail conf (removing the masquerade stuff from /etc/mail/sendmail.mc)
When i try to send a mail using command line ( sendmail ... -f user#mydomain.com receiver#otherdomain.com) the mail is allways deffered:
webserv sendmail[3694]: q2P2nP4M003694: Authentication-Warning: mydomain.com: username set sender to user#mydomain.com using -f
webserv sendmail[3694]: q2P2nP4M003694: from=user#mydomain.com, size=2124, class=0, nrcpts=1, msgid=<d9dc266122bf46d87b59e20cbd0c7432#www.mydomain.com>, relay=username#localhost
webserv sm-mta[3695]: q2P2nPOE003695: from=<user#mydomain.com>, size=2315, class=0, nrcpts=1, msgid=<d9dc266122bf46d87b59e20cbd0c7432#www.mydomain.com>, proto=ESMTP, daemon=MTA-v4, relay=localhost.localdomain [127.0.0.1]
webserv sendmail[3694]: q2P2nP4M003694: to=receiver#otherdomain.com, ctladdr=user#mydomain.com (1001/1001), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32124, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q2P2nPOE003695 Message accepted for delivery)
webserv sm-mta[3697]: q2P2nPOE003695: to=<receiver#otherdomain.com>, delay=00:00:42, xdelay=00:00:42, mailer=relay, pri=122315, relay=26, dsn=4.0.0, stat=Deferred
However if i flush the queue (force the mail to be sent), the mail is successfully sent.
I tried to bypass my problem by using my dedicated mail server box (another domU on the same network of this one, running under debian squeeze and using postfix as MTA, working fine) as a smarthost, but the mail never used the smarthost.
So if you have any advices I'll be glad to hear them.
Regards
PS: It is required that the MTA on the webserv domU is sendmail

I didn't solve the problem with sendmail-mta, however i found out that postfix use "sendmail" as binary name. So i uninstalled sendmail then installed postfix, which worked fine out of the box.
I specified i wanted sendmail mta because i needed the name of the binary to be sendmail.
So question closed.

Related

Denyhosts on Centos7 option DENY_THRESHOLD_INVALID does not work

using centos7 and denyhosts 2.9 i noticed some strange behavior.
My config is set to:
DENY_THRESHOLD_INVALID = 3
DENY_THRESHOLD_VALID = 10
Which, in my understanding is like: after 3 failed login attempts of NON-EXISTING users from hosts X, deny that host.
After 10 failed logins attempts from EXISTING users from hosts X, deny that host.
While the latter works just fine, the DENY_THRESHOLD_INVALID = 3 setting does not work.
What i noticed is that the /var/log/secure, that danyhosts parses, does handly logns from non-existing accounts and logins from account that exist but are using the wrong pasword, are handled differently.
Aug 10 12:32:42 ftp sshd[27176]: Invalid user adminx from xxx.128.30.135 port 42800
Aug 10 12:32:42 ftp sshd[27176]: input_userauth_request: invalid user adminx [preauth]
Aug 10 12:32:42 ftp sshd[27176]: Connection closed by xxx.128.30.135 port 42800 [preauth]
vs.
Aug 10 12:33:46 ftp sshd[27238]: Failed password for exchange from xxx.128.30.135 port 42802 ssh2
Does anyone know of denyhosts has problems parsing the /var/log/secure file on centos with non-existing accounts vs. existing accounts that use wrong passwords?
Denyhosts debug log also does not say anything. It seems to ignore the login attempt from non-existend users.
any help would be appreciated. Thanks.

Net::SMTP can't connect on Windows 8

I wrote a minuscule script to test an SMTP connection with Net::SMTP:
#!/usr/bin/perl -w
use strict;
use Net::SMTP;
my $smtp = Net::SMTP->new( 'mypc', Port => 10025, Timeout => 30, Debug => 1 );
die "Couldn't connect to SMTP server" unless $smtp;
An SMTP server is running on mypc:10025 and dumps all I/O it does. When I execute the script from a Debian Linux machine (64bit, Perl v5.20.2), the SMTP server shows I/O activity and everything works as expected:
zb226#debian8:~$ ./net_smtp.pl
Net::SMTP>>> Net::SMTP(2.33)
Net::SMTP>>> Net::Cmd(2.30)
Net::SMTP>>> Exporter(5.71)
Net::SMTP>>> IO::Socket::INET(1.35)
Net::SMTP>>> IO::Socket(1.38)
Net::SMTP>>> IO::Handle(1.35)
Net::SMTP=GLOB(0x118adc0)<<< 220 Hi
Net::SMTP=GLOB(0x118adc0)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x118adc0)<<< 250 OK
When I execute this on the Windows 8 machine (64bit, Strawberry Perl 5.22.0), no connection is established. I can see this by the total absence of I/O in the SMTP server. Net::SMTP does not connect. The script just dies, as is expected in this case:
C:\test>perl -w net_smtp.pl
Couldn't connect to SMTP server at net_smtp.pl line 5.
Observations:
Interestingly, the script dies after what feels like 3 seconds, not the 30 seconds I specified.
I can use telnet.exe to connect to the SMTP server and it shows I/O activity.
I have tried turning off the Windows firewall completely without any improvement.
I had an admin disable the corporate anti-virus software temporarily without any improvement.
Updating Strawberry Perl to the currently recommended 5.24.0.1 didn't help either.
I'm not sure what to try next.
Edit: Tried a small IO::Socket::INET script to verify perl can actually connect on this Windows PC:
#!/usr/bin/perl
use strict;
use IO::Socket::INET;
my #hosts = qw/ mypc:10025 /;
foreach my $host ( #hosts ) {
my $open = defined IO::Socket::INET->new(PeerAddr => $host, Timeout => 5) || 0;
printf "Probed %s -> %s \n", $host, $open ? 'ok' : 'NOK';
}
I see I/O in the SMTP server and it works as expected:
C:\test>perl -w io_socket.pl
Probed mypc:10025 -> ok
Based on the information from the other answer the underlying problem is, that
the hostname used resolves to both an IPv4 and IPv6 address,
the SMTP server is only listening at the IPv4 address or the IPv6 address is blocked by a firewall,
and a recent version of Net::SMTP is in use which contrary to older versions transparently supports IPv6 and IPv4.
Because if the IPv6 support and the commonly used preference for the newer IPv6 against IPv4 Net::SMTP will resolve the hostname and then try the IPv6 address - and fail to connect. Direct use of IO::Socket::INET instead works because it is doing only IPv4 (contrary to IO::Socket::IP used by Net::SMTP).
The reason it works on Linux and not on Windows is probably the different version of Perl: the new version of Net::SMTP with built-in IPv6 (and SSL) support ships only since Perl 5.22 as a CORE module, i.e. the Perl on Windows (5.22) has the version with IPv6 support while the Perl on Linux (5.20) does not.
There are several ways to fix the problem:
use the IPv4 address directly instead of the hostname
make the SMTP server listen on both IPv4 and IPv6
or specify the address family to use, i.e.
my $smtp = Net::SMTP->new( 'mypc', ..., Domain => AF_INET );
Following this discussion, I found that the problem is related to IPv6. Opening C:\strawberry\perl\lib\Net\SMTP.pm and changing the line...
our #ISA = ('Net::Cmd', $inet6_class || 'IO::Socket::INET');
...to...
our #ISA = ('Net::Cmd', 'IO::Socket::INET');
...makes the original script run:
C:\test>perl -w net_smtp.pl
Net::SMTP>>> Net::SMTP(3.08)
Net::SMTP>>> Net::Cmd(3.08)
Net::SMTP>>> Exporter(5.72)
Net::SMTP>>> IO::Socket::INET(1.35)
Net::SMTP>>> IO::Socket(1.38)
Net::SMTP>>> IO::Handle(1.36)
Net::SMTP=GLOB(0x58e8fc)<<< 220 Hi
Net::SMTP=GLOB(0x58e8fc)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x58e8fc)<<< 250 OK
For now, I'm relieved because I can continue my work, but if anybody has further clues as to how to avoid this ugly patch, I'll happily accept an elaborated answer.
Edit: Correspondingly and without patching, disabling IPv6 does the trick as well.

Linux fetchmail POP3 connection error

Slackware OS, trying to setup fetchmail
I have coded this .fetchmailrc file:
set daemon 600 //fetches mail every hour or 60 minutes.
set logfile /root/fetchmail.log
poll 10.200.***.** protocol POP3
user "bob" password "bob" is "bob" here preconnect "date>>/root/fetchmail.log"
ssl
no rewrite
keep
It worked before but now it is failing to retrieve mail, i checked the fetchmail.log file and i get this error:
Thu Nov 5 10:15:32 GMT 2015
fetchmail: connection errors for this poll:
name 0: connection to 10.200.***.**:pop3s [10.200.***.**/995] failed: Connection refused.
fetchmail: POP3 connection to 10.200.***.** failed: Connection refused
fetchmail: Query status=2 (SOCKET)
I've reset the daemons, ended the process and no progress.
I had exactly the same problem on a Mageia 5 Linux. Apparently, I
solved it by redoing network configuration, which the Mageia can do
with a single click on the relevant Configure button in the Network
Center window.
I did not touch my .fetchmailrc file.

Setup linux server to use Exchange server as relay

It used to be working, but out of the blue, it stopped sending mail. I thought I set everything up in both linux and exchange to function correctly, but we're not receiving the emails - internally or externally.
I'm not that knowledgeable about linux, so I use webmin to get around.
So, we have our shopping cart and online forms on the linux server that will email users confirmations and such. It won't receive any mail, so I don't need to worry about that. It only sends mail out, both inside our network, and outside. Here is a recent addition to the mail log:
Dec 6 11:51:04 istalinux2 sendmail[1696]: rB6Gp4lr001696: from=www-data, size=246, class=0, nrcpts=1, msgid=, relay=www-data#localhost
Dec 6 11:51:05 istalinux2 sm-mta[1697]: rB6Gp4hY001697: from=, size=485, class=0, nrcpts=1, msgid=, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Dec 6 11:51:05 istalinux2 sendmail[1696]: rB6Gp4lr001696: to="John Smith" jsmith#ista-in.org, ctladdr=www-data (33/33), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30246, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (rB6Gp4hY001697 Message accepted for delivery)
Dec 6 11:51:05 istalinux2 sm-mta[1699]: rB6Gp4hY001697: to=jsmith#ista-in.org, delay=00:00:01, xdelay=00:00:00, mailer=relay, pri=120485, relay=10.20.51.30, dsn=5.1.2, stat=Host unknown (Name server: 10.20.51.30: host not found)
Dec 6 11:51:05 istalinux2 sm-mta[1699]: rB6Gp4hY001697: to=www-data#istalinux2.ista-in.org, delay=00:00:01, mailer=local, pri=120485, dsn=5.1.1, stat=User unknown
Dec 6 11:51:05 istalinux2 sm-mta[1699]: rB6Gp4hY001697: rB6Gp5hY001699: postmaster notify: User unknown
Dec 6 11:51:05 istalinux2 sm-mta[1699]: rB6Gp5hY001699: to=root, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30000, dsn=2.0.0, stat=Sent
I have a receive connector set up in Exchange to receive incoming mail from our linux server and pass it through.
I am using sendmail in linux - but I honestly don't care how it's set up, as long as it works and doesn't break, lol. Please help me make sure all my settings in linux are correct ... and keep in mind that I am NOT a linux guy.
The problem seems to be this part:
relay=10.20.51.30, dsn=5.1.2, stat=Host unknown (Name server: 10.20.51.30: host not found)
I assume that 10.20.51.30 is the ip address of your exchange server. Now, without seeing the actual configuration files, it's a bit hard to find out what you did wrong, but normally, when you specify a mail relay, you have to use either a) a real dns name, not an ip, or b) enclose the ip in [] brackets - just like the line before that one, which says relay=[127.0.0.1].
Try enclosing the 10.20.51.30 in [] brackets, or, use the name of the exchange server instead of the IP, and make sure your DNS server can resolve that name.

Linux - 550 Access denied - Invalid HELO name(See RFC2821 4.1.1.1)

I am trying to send an email via Linux server but i never receive it. I'm currently using putty and I use
# php -r 'mail("*****#gmail.com","Test subject", "Test Message","From: *****#gmail.com");'
Then i go check my message with
cat /var/spool/mail/
and i got this
----- The following addresses had permanent fatal errors -----
<****#gmail.com>
**(reason: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1))**
----- Transcript of session follows -----
... while talking to domain.ca.:
>>> MAIL From:<*****#****> SIZE=568
<<< **550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)**
554 5.0.0 Service unavailable
I searched on the web and i can't find an answer
some people say its an authentification problem but they are talking mainly about outlook.
I don't know if it help, but when I do telnet and ehlo i got this
# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 *** ESMTP Sendmail 8.14.4/8.14.4; Fri, 27 Sep 2013 14:47:10 -0400
# ehlo localhost
250-****Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-DELIVERBY
250 HELP
I think it's missing
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
I don't know if it's because of that i have my error and that i can't send an email? If yes, I don't know what to do to make this apear.
Can someone help me please? I'm new with linux and php mail
If it's a VPS or a Dedicated Server try changing the hostname to something resolvable like server#mydomain.com with valid A records for the same
I found the following website useful
How to fix Invalid HELO Name error

Resources