Yahoo and Hotmail won't reply HELO/EHLO to my SMTP server - sockets

I've been looking for an answer to this all over the internet, and sadly I've come nowhere near one.
Today I decided to write a SMTP server for sending/recieving emails from my RPi. I wanted to do it from scratch, so switching to Postfix is not an option. I've wrote my code on Java and all the connections are handled with sockets.
My server works like -as I understood- most SMTP servers work:
- Email sender connets to my server on port 25.
- I say "220 Hello, welcome to my server"
- They then reply HELO or EHLO and so the communication goes on.
This has worked great so far with GMail, some anonymous email sending websites, mail.com, etc, but I can't make it work with Hotmail and Yahoo. They connect, I send them the "220 Hello, etc" line, but they don't reply HELO nor EHLO nor anything at all.
Yahoo has been trying to connect for a while now, but they don't reply anything at all. Neither does, again, Hotmail.
Do you know if they work in some special way, if I am messing something up with the protocol, or what could be happening?
Thank you very much.
EDIT
Some other things:
- I'm using a No-ip address.
- I'm listening to ports 25, 465 and 587, and all of them have been opened in my router.

Make sure your lines end with \r\n and not just \n.

Related

SMTP: Remote client not responding to 220

Recently I've been experimenting with a simple script that listens on port 25, and receives and logs any incoming emails.
It's a very primitive script, and it doesn't implement the SMTP protocol at all. It just simply spits out canned replies, and it works something like this:
Wait for an incoming socket.
Send "220 example.com ESMTP Postfix".
Receive one line, typically like "EHLO other.com".
Send "250 example.com, I am pleased to meet you".
Receive lines until "DATA", reply with "250 Ok" every time".
Send "354 End data with .".
Receive lines until "." is received.
Send 250 Ok: queued as 12345.
Receive any final lines then close the socket.
(example.com is in place of my real domain's FQDN.)
It's a very crude script indeed; however, for the past few months it's worked perfectly for every email that I needed to receive. I can receive fine from Gmail, Protonmail, verification emails, etc. I also caught some internet-wide scans, so it serves as a fun honeypot too.
Today, I tried to receive a Microsoft account verification email to register a Microsoft account. The remote client didn't seem to respond to the 220 at all!
# nc -l -v -p 25
Listening on [0.0.0.0] (family 0, port 25)
Connection from mail-co1nam03on0003.outbound.protection.outlook.com 56725 received!
220 example.com ESMTP Postfix
No matter what I tried, the client wouldn't send anything. What am I doing wrong? Any ideas are welcome.
tripleee solved this in the comments, so I'm posting it as an answer here for everyone to see. The problem is that I was giving just LF as a newline, not CRLF. So I replaced all the '\n' with '\r\n' in my code, and that fixed it. I guess the other mailservers were just being lenient with me.

Can't stablish SMTP connection with Yahoo, I think the TCP handshake is failing

I'm trying to stablish a SMTP connection with hotmail or yahoo (both giving the same issue). They connect to my server (192.168.1.220) on port 25 and I send the 220 confirmation, but they don't reply with HELO, EHLO nor anything.
So I scanned the packages and I found this:
http://i.stack.imgur.com/Kj4r0.jpg
As far as I see, SYN is sent without any problems, SYN-ACK works right, then ACK doesn't reply with the right Seq value (it should be 2, right?).
Do you know what could be causing the connection issue? Should I try UDP or nothing here is wrong and I am misunderstanding the whole situation?
Thank you very much!
The problem wasn't here.
We were sending our 220 message just with \n and no \r. So we sent "220 Hello\n\r" and it worked.

PHPMailer EHLO Error

I have a problem for a couple of days ago me going crazy, I have a script that sends mails using phpMailer and arsys.
The fact is that the overnight stops working, check the code and seems fine, it's more, it works correctly if I run it from the test server that comes through another IP.
I found that the server was not on any spam blackList and found the reference to be to a PBL, me worry about removing it from there.
Anyway, I still can not send mail from that server and both my other test script I programmed work correctly on development server but not on the production server.
The error that is specifically this
SMTP -> ERROR: EHLO not accepted from server:
SMTP -> ERROR: HELO not accepted from server: 220 ESMTP Postfix smtp-04.servidoresdns.net
SMTP -> ERROR: AUTH not accepted from server: 250-250-llsg993-a04.servidoresdns.net PIPELINING 250-SIZE 51200000 250-ETRN 250-250-STARTTLS AUTH DIGEST-MD5 CRAM-MD5 LOGIN PLAIN 250-AUTH = DIGEST MD5 CRAM-MD5 LOGIN PLAIN 250-250 8BITMIME ENHANCEDSTATUSCODES
It says it can not authenticate the credentials are fine but since the same script from another server goes perfectly.
Also came through a tcptraceroute to port 25 SMTP server.
Only strange thing I see is that when running
tcptraceroute p 25 smtp.miservidor.com
He says:
Sorry, Local Requested port is already in use. Use P, instead of p, to override.
But after using P instead of p and functions
Anyone shed me some light on this?
Who may be filtering my IP address ??
It's very common for ISPs to block outbound connections to port 25 by default. Try using SMTPSecure = 'tls' and Port = 587 - that server definitely responds on that port.
Connection problems are covered in the PHPMailer docs.
I noticed that never answered this question, the problem was the time, the function did not have enough time to contact with server. I increased the time in phpMailer class and everything went back to work.

Mail not getting send to specific domains

We have a VPS with CentOS combined with DirectAdmin which we use for a Magento shop. This runs fine, except for sending email.
Problem:
It appears that some specific domains won't receive our emails and we get a bounce. If we use any other email sending systems, the mails arrive without problems.
The bounce mail contains the following error:
SMTP error from remote mail server after HELO Company-Shops:
host mx-cluster-b2.one.com [IP ADRESS]: 504 5.5.2 :
Helo command rejected: need fully-qualified hostname
After googling and trying things for a week now, I am a bit lost. I tried checking postfix in CentOS, but this is not installed and I'm not quite sure if this is needed.
Possible issue?
I believe the hostfile in CentOS is setup incorrectly:
127.0.0.1 localhost localhost.localdomain localhost4 ... etc
OUR IP Company-Shops
'Company-Shops' should probably be a domain name, am I right? The same as the rDNS. But I'm afraid if I change this it will kill my site and whatnot. I'm not sure if this entry correlates with the 'company-Shops' helo label in the bounce error.
Some extra info:
- We use the webmail Roundcube from DirectAdmin
- At the moment we run one shop, but this might grow a bit (multiple sites on 1 IP)
- We don't use subdomains
- We've set up a reverse DNS, with the domain
Is there anyone with similiar experiences or with a bit more knowledge about this subject? I appreciate any advice we can get, as we are stuck..
Many thanks.
Yes, that's right: your mail server should identify itself using a fully-qualified domain name when it connects to send mail via SMTP. You don't say what mail server you're running, but since you're using DA, it's probably Exim. If so, you want to edit /etc/exim.conf and set primary_hostname to the FQDN of your server.
This would also be a good time to double-check that reverse DNS is set up properly for your IP address. Many hosts will also reject email from servers on IPs without a valid rDNS record.
I'm not familiar with Magento, but I can't see any way that changing the Exim configuration in this way could impact that program.

Skpsmtpmessage: which server should i use for gmail

I got this project "skpsmtpmessage" and I tried to send mail first. So I changed all the mail id to gmail id. But replay host is problem. I tried smtp.gmail.com, smtp.google.com, smtp.googletalk.com. But when I run my program, I get error that "Unable to connect server"
Which relay host should I use for gmail.
The correct SMTP server for Gmail is smtp.gmail.com, but I don't know how to help you further, the question is pretty vague.
You can also take a look at the configuration instructions for using Gmail on the iPhone to see if you're making a mistake with another parameter.