LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 11-25-2014, 01:12 AM   #1
G@uri
LQ Newbie
 
Registered: Nov 2014
Posts: 5

Rep: Reputation: Disabled
Question Postfix- How to set relay_domains to any destination or any other alternative


Hi,

I have done with the basic setup of Postfix in Ubuntu 14.04.
main.cf is like this.
myhostname = server1.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = server1.example.com, example.com, localhost.example.com, localhost
relayhost =
relay_domains = server1.example.com,gmail.com,yahoo.co.in
mynetworks = 127.0.0.0/8

This is working for the recepient domains server1.example.com,gmail.com,yahoo.co.in. I cannot predict the recepient's domain or email-address in my app. It can be anything (like hotmail.com) other than mentioned in relay_domains. So I need to set destination domain for all.
I have tried relay_domains= $mydestination,but its not working.
Please help me out.
Thanks in advance.
 
Old 11-25-2014, 08:22 PM   #2
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware
Posts: 6,828
Blog Entries: 7

Rep: Reputation: Disabled
Hi & Welcome to Linux Questions.

Going through the Postfix Basic Configuration might help.
http://www.postfix.org/BASIC_CONFIGURATION_README.html

An example of default setting:
Code:
    /etc/postfix/main.cf:
        mydestination = $myhostname localhost.$mydomain localhost
This tutorial looks like a good place to start.
https://rudd-o.com/linux-and-free-so...x-in-5-minutes

This cmd should work for you.
Code:
mydestination = $myhostname localhost.$mydomain
There is another cmd on that page for multipule destinations but the DNS record has to exist and point to your server.

-::-Postfix will let e-mail clients relay mail, only if they run in the same server-::-

HTH
 
Old 11-28-2014, 04:39 AM   #3
G@uri
LQ Newbie
 
Registered: Nov 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hi, I have configured postfix like that only.
There is one property relay_domains in main.cf and it is set to gmail.com. so I am able to send emails to gmail.com. But I don't want this dependency. I wanted to set it to all domains. Please help me out.
Here is my main.cf

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
#smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated
myhostname = scen.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = scen.com, ip-10-84-168-130, localhost.localdomain, localhost
relayhost =
relay_domains = gmail.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
 
Old 11-28-2014, 06:12 AM   #4
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
@Gauri: seeing your configuration .. do you know what relay does ?
did you tried sending a test mail to see if your config works ?
if yes,
what did you see, errors/logs ?
 
Old 11-28-2014, 06:29 AM   #5
G@uri
LQ Newbie
 
Registered: Nov 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hi SAbhi,

I tried it with standalone java program.
It was working for recepient xxxx@gmail.com only coz relay_domains=gmail.com
But it is throwing exception for any other domain like recepient xxxx@yahoo.co.in
Exception is Relay Access Denied.
It will work if I specify yahoo.co.in in relay_domains.
But for me it should work for all domains.
Should I have to remove relay_domains property
Please provide me a solution for it
I have already searched a lot for it.
I have pasted my full main.cf here.
 
Old 11-28-2014, 08:44 AM   #6
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
Gauri, there can be multiple relay domains defined in one configuration separated by comma.
Give it a try.

i would also like to ask you to read the manual for postfix to understand how it works.. if you already not known of it.

Last edited by SAbhi; 11-28-2014 at 08:47 AM. Reason: suggestion
 
Old 11-30-2014, 11:11 PM   #7
G@uri
LQ Newbie
 
Registered: Nov 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanx SAbhi, I know, it will surely work if I configure it for multiple relay domains separated by comma.
But I don't want such hardcoded thing.
It will be restricted to that domains only.
 
Old 12-01-2014, 10:28 PM   #8
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
In that case you can make a file with all relay domains in it and use
Code:
 cat >relay_domains_list
domain1 OK
domain2 OK
..

#and then defining below path in relay_domains

hash:path/to/relay_domains_list
to set the relay domains. I am not suggesting allowing relay from anyone, it can be dangerous.

Last edited by SAbhi; 12-01-2014 at 10:30 PM.
 
Old 12-01-2014, 10:53 PM   #9
G@uri
LQ Newbie
 
Registered: Nov 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Ok Thanks SAbhi
 
Old 12-01-2014, 11:35 PM   #10
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware
Posts: 6,828
Blog Entries: 7

Rep: Reputation: Disabled
SAbhi:

Thank you; for helping!-
 
Old 12-02-2014, 02:33 AM   #11
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,418

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Code:
relay_domains = server1.example.com,gmail.com,yahoo.co.in
I'm sure this setting is *really* NOT what you want.
It means that ANYONE can send ANY mail to ANY address in those domains - meaning your server could be easily used to spam gmail and yahoo users flat out - until they blacklist you, which won't be very long at all, and will be very difficult to undo.

What you *should* look into is the $mynetworks settings (for local or fixed clients, such as your webserver) or authentication (for roaming clients).
 
Old 12-02-2014, 08:59 AM   #12
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 664

Rep: Reputation: 80
Quote:
Originally Posted by descendant_command View Post
Code:
relay_domains = server1.example.com,gmail.com,yahoo.co.in
I'm sure this setting is *really* NOT what you want.
It means that ANYONE can send ANY mail to ANY address in those domains - meaning your server could be easily used to spam gmail and yahoo users flat out - until they blacklist you, which won't be very long at all, and will be very difficult to undo.

What you *should* look into is the $mynetworks settings (for local or fixed clients, such as your webserver) or authentication (for roaming clients).
@Gauri: this is something you must look into.. Thanks @descendant_command
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Postfix : logging destination smtp dazdaz Linux - Networking 1 03-07-2014 04:08 AM
[SOLVED] Postfix remote users/smartphones must send through relay_domains tardis1 Linux - Server 4 08-03-2012 09:01 AM
Rsync set permissions destination Abstractt Linux - General 3 09-30-2010 03:05 AM
database relay_domains.db is older than source file relay_domains homyangcha Linux - Newbie 9 02-11-2009 02:44 AM
Postfix Rewrite Destination Domain Name? doctorcisco Linux - Server 2 11-03-2007 12:02 PM


All times are GMT -5. The time now is 09:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration