Postfix SMTP Relay Access Denied

al flag

I know that there are already many similar queries on this site, but I could not find a solution for myself in any of them. I have postfix version 3.6.4 configured for smtp. I need it to forward mail to recipients only from google. But when I try to send the mail, I get an error:

Jun  7 12:23:01 ubuntu-2gb-hel1-1 postfix/smtpd[20535]: connect from[]
Jun  7 12:23:01 ubuntu-2gb-hel1-1 postfix/smtpd[20535]: NOQUEUE: reject: RCPT from[]: 454 4.7.1 <[email protected]>: Relay access denied; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<>

When I add the Google IP address(example: to the mynetworks section, everything works. But it's not convenient, because I don't know all the Google addresses. Therefore, I would like to limit access by the domain name Google ( To override all google subdomains I used regexp but it doesn't work. Can someone tell me how to fix this problem?


ws flag
Please don't post images of text you can cut and paste.
cu flag

Add the following lines to the configuration file "/etc/postfix/":

smtpd_restriction_classes = google_domains
google_domains = check_sender_access regexp:/etc/postfix/google_domains

smtpd_recipient_restrictions =
   check_helo_access regexp:/etc/postfix/google_domains
   check_client_access regexp:/etc/postfix/google_domains

Create the file /etc/postfix/google_domains and add the following line:

/^.*\.google\.com$/   google_domains

Reload Postfix to apply the changes.

Tarik avatar
al flag
Thanks for the help. Unfortunately, this option didn't work for me. I restricted access by subnet using google article :
I sit in a Tesla and translated this thread with Ai:


Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.