19

hi i wanted to send mail via smtp protocol to one of my gmail's accounts...

i tried but finally it occurred and error :

telnet> open alt4.gmail-smtp-in.l.google.com 25
Trying 74.125.131.27...
Connected to alt4.gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP b4si2095585vdw.57 - gsmtp
HELO stackoverflow.com
250 mx.google.com at your service
MAIL FROM: <test@stackoverflow.com>
250 2.1.0 OK b4si2095585vdw.57 - gsmtp
RCPT TO: <■■■■@gmail.com> // filtered ;)
250 2.1.5 OK b4si2095585vdw.57 - gsmtp
DATA
354  Go ahead b4si2095585vdw.57 - gsmtp
test
ok
it done
.
550-5.7.1 [5.22.81.102] The IP you're using to send mail is not authorized to
550-5.7.1 send email directly to our servers. Please use the SMTP relay at your
550-5.7.1 service provider instead. Learn more at
550 5.7.1 http://support.google.com/mail/bin/answer.py?answer=10336 b4si2095585vdw.57 - gsmtp
Connection closed by foreign host.

so now how can i send mail without having this problem ?

Rosdi Kasim
  • 24,267
  • 23
  • 130
  • 154
Amir Hossein
  • 249
  • 2
  • 4
  • 14

3 Answers3

32

This is because Google will reject any emails sent from IP in the spamhaus database.

What you need to do is go to http://www.spamhaus.org/lookup/ and follow the instruction there to remove your server ip from spamhaus database.

Please also follow this guide: Prevent mail to Gmail users from being blocked or sent to spam

Rosdi Kasim
  • 24,267
  • 23
  • 130
  • 154
  • 3
    I found out that my domain was in the Spamhaus database weeks ago so I removed it from there, but GMail still won't take email from my site. I double checked now with that lookup URL there and they say there are no issues with my site. Any idea on how much time could take for GMail to refresh this? – Fran Marzoa Jun 22 '21 at 15:45
  • @FranMarzoa I was in the same situation as you a couple months back, it takes a couple days. I'm in the same situation now, it's been around 24 hours. I assumed they would fetch an updated list around midnight but they haven't and then remembered that it took a couple days last time. Hope this helps. – MartinNajemi Jun 26 '21 at 14:16
  • 2
    @MartinNajemi Unfortunately for me it's still failing and it's been more than a week since I detected the issue. I just found out the whole net range in which my server is has been blacklisted by that UCEPROTECT level 3 SCAM. I had hoped GMAIL wasn't trusting such a shady list but I'm starting to think they are actually... I guess I may need to move my mail server elsewhere. – Fran Marzoa Jun 27 '21 at 16:20
  • 1
    Spamhaus allows users to de-blacklist their IPs, but it takes long for these changes to be active (weeks, possibly months or longer). The workaround is to snapshot/backup your VPS, then delete it, then spin up a new one and make it a clone of the snapshot you just made. The new VPS will be the same as the old one, but will have a new external IP. In my case, I had to spin up and destroy two additional VPSs before Digital Ocean provided a non-blacklisted IP for the new VPS. Just keep spamhaus open and check the IPs until the newly assigned one passes the test. – oemb1905 Sep 02 '22 at 16:17
  • Is there any progress? I'm having the same problem. I am not in the Spamhaus database, but it gives the same error when sending to gmail address. – emrez Sep 05 '22 at 17:07
1

You can find the answer at the link in the last line of the Google mail served response:

'The IP you're using to send email is not authorized...'

In order to prevent spam, Gmail refuses mail from IP addresses that are not authorized to send mail. The determination of whether or not an IP address is authorized to send mail is made by the ISP that provides you with the IP address. This list typically contains consumer IP ranges offered for dialup, DSL, or other broadband access.

What can I do to fix this?

Your ISP may provide SMTP relays which will accept mail from your IP, and these servers should be authorized to send mail. Some ISPs may provide a way to get an IP that is authorized, either by upgrading to business class service or static IP service. You should reach out to your ISP to see what options are available.

Another alternative is to send mail through your own domain’s servers, either by configuring them to allow relay from your IP address, or by using MSA (mail submission agent). Learn how to use Gmail to send mail from a different address.

Please note that we are unable to whitelist IP addresses or otherwise make exceptions.

In other words, if your IP address is not authorized by your ISP to send mail, you should send your mail through:

  1. Your provider mail server (SMTP relay)
  2. Your own domain mail server.

Mail servers must meet a number of requirements to prevent their messages from being blocked, e.g. have a PTR record. The use of authentication methods such as SPF, DKIM or DMARC minimize the chance that messages are marked as spam.

chus
  • 1,577
  • 15
  • 25
  • No, that's not necessarily correct. If the ISP or host provider provides users with PTR records, then you can directly send and it is merely because the IP was formerly abused/blacklisted that you cannot. This commonly happens at VPS providers (who do offer PTR and allow mail servers) because the IPs are used/reused, so they might be blacklisted from a prior owner's misuse. – oemb1905 Aug 13 '22 at 20:21
  • In case the recipient's mail server applies mechanisms such as SPF or DKIM, then a PTR record will not be sufficient to send a mail message directly to the recipient's server. – chus Aug 19 '22 at 21:44
  • Google's servers do not block incoming mail that lacks SPF and/or DKIM. They do reject incoming mail that lacks a PTR record (reverse DNS record) and/or if the external IP is blacklisted in Spamhaus due to prior abuse. It is not true that "mail should not be sent directly from regular users to the recipient mail servers" as this is what millions of small businesses and power users do on a daily basis for WordPress, cron alerts, backup scripts, and so on. A public-facing IP requires reverse DNS and nearly all all incoming servers honor BLs. SPF/DKIM has nothing to do with this issue at all. – oemb1905 Aug 27 '22 at 12:48
  • It is true that most providers will reject messages coming from a server without a PTR record. But according to [Google's guidelines](https://support.google.com/mail/answer/81126), messages sent from providers without SPF records are more likely to be marked as spam. – chus Sep 01 '22 at 02:32
  • The error code above is caused by one of two reasons: the server is denying the email because the external IP has a blacklisting or because the external IP lacks a PTR / reverse DNS. In this situation, and as opposed to the scenario you just outlined, the email was rejected and not sent on to the recipient. The documentation you provided, as opposed to the OP, is referring to how SPF records are used to rate the quality and spam potential of emails that are already accepted (i.e., they already passed PTR / Blacklisting checks). – oemb1905 Sep 02 '22 at 16:11
-2

I had this problem with one of my hotmail addresses, using Thunderbird on Kubuntu. Tried changing sever settings, passwords etc to no avail. In desperation, I deleted the offending email address through "account settings" "account actions" (bottom left of window). If you are on POP3 you will loose all your emails, so make sure you're on IMAP. You then just select "add email" in Thunderbird and the email is put back as it should be and works perfectly.

kaspin
  • 11
  • 2
    It would be great if you could add an explanation about *why* your code solves the issue. ;) – Roberto Caboni Dec 05 '19 at 15:07
  • Similarly to chus's answer above, you are incorrectly conflating mail clients with mail transfer agents (MTAs). The OP is using their own MTA, not a desktop client. When using your own MTA on your own server/VPS, the external IP must be public facing, must pass PTR (reverse DNS), and most servers for intended recipients honor/observe Spamhaus blacklistings, so if/when you use an external IP from a major vendor, you should verify that your IP is not blacklisted. – oemb1905 Sep 02 '22 at 16:22