Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

ok - i give up trying to find the answer to this so here i am :)

I have postfix/dovecot setup using virtual accounts. I basically followed this guide http://pietervogelaar.nl/ubuntu-12-04-install-postfix-dovecot-and-vimbadmin/

But what I ideally want is to set up a mail server to be an endpoint for some domains, whilst relay others.

Example

example.com is a virtual domain hosted locally on the mail server. info@example.com is an email address on the local server so mails are stored in /var/vmail/example.com/info

otherdomain.com is a domain that needs all messages relayed to some.other-server.com whilst going through spam/av checking first. no mails or accounts are stored locally.

EDIT

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
content_filter = amavis:[127.0.0.1]:10024
dovecot_destination_recipient_limit = 1
enable_original_recipient = no
header_checks = regexp:/etc/postfix/header_checks
inet_interfaces = all
mailbox_size_limit = 0
mydestination = mx1.itmanx.com, localhost, localhost.localdomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, reject_invalid_hostname, reject_unauth_pipelining, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_rbl_client sbl.spamhaus.org, permit
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous, noplaintext
smtpd_sasl_tls_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
virtual_alias_maps = mysql:/etc/postfix/mysql/virtual-aliases.cf
virtual_gid_maps = static:5000
virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual-mailboxes.cf
virtual_transport = dovecot
virtual_uid_maps = static:5000
share|improve this question
    
Could you clarify what exactly do you want to get from your current mail server? –  ALex_hha Jul 30 '13 at 10:45
    
Hi Alex. I want it to work as a normal mail server, collecting emails to virtual accounts. But I also want it to act as a relay for some domains which are hosted on an internal Exchange server. I have tried several options including virtual_transport and relay_domains but for the domain i want relayed, it keeps saying 'user not in virtual users list' and even if i add the user, it still doesnt relay. –  Christian Jul 30 '13 at 16:11
    
It mean that the destination mail address is not in relays domain. Could you show the output of postconf -n –  ALex_hha Jul 30 '13 at 18:10
    
Added to the question –  Christian Jul 30 '13 at 21:05
    
I see, I don't work with vimbadmin (only with postfixadmin). When you create domain you must select "relay" in the transport combobox –  ALex_hha Jul 30 '13 at 22:35
show 1 more comment

2 Answers

I don't see any transport maps in your config. It must be something like following

transport_maps = mysql:/etc/postfix/sql/relay_transport.conf
relay_domains = mysql:/etc/postfix/sql/transport.conf

/etc/postfix/sql/relay_domain.conf

user = postfixadmin
password = password
hosts = localhost
dbname = postfixadmin
query = SELECT domain FROM domain WHERE domain='%s' and transport = 'relay' and active = 1

/etc/postfix/sql/transport.conf

user = postfixadmin
password = password
hosts = localhost
dbname = postfixadmin
query = SELECT transport FROM domain WHERE domain='%s' and active = 1

Note: in the description field you must specify ip address of the relay server

You can get more info at http://sourceforge.net/apps/mediawiki/postfixadmin/index.php?title=Relay_Domains

share|improve this answer
    
Hey Alex - Thanks for your reply. I'm just starting from scratch with my mail server install so will let you know if this worked. –  Christian Aug 1 '13 at 7:25
    
Hi Alex - well, im pretty much a genius on postfix now :) and what you've put is wrong because relay_transport doesnt support lookups, it should just be 'relay'. –  Christian Aug 1 '13 at 13:19
    
You are wrong. "a string of the form transport:nexthop, where transport is the name of a mail delivery transport defined in master.cf. The :nexthop destination is optional; its syntax is documented in the manual page of the corresponding delivery agent" - postfix.org/postconf.5.html#relay_transport –  ALex_hha Aug 1 '13 at 15:09
    
Exactly "a string", not a lookup table. Check your mail.log when you try to send an email to a relay domain and you're probably get private/mysql unknown transport - but granted, i shoudlnt have said "just be 'relay'" because as you say, it can be relay:[destination] –  Christian Aug 1 '13 at 16:33
    
Shame on me, you are right. I have updated my answer. –  ALex_hha Aug 1 '13 at 17:17
show 2 more comments
up vote 0 down vote accepted
# Which domains will this server relay
relay_domains = $mydestination, mysql:/etc/postfix/mysql/relay_domains

# Which domains/accounts will this server store
virtual_alias_domains = mysql:/etc/postfix/mysql/virtual_alias_domains
virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps
virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_mailbox_domains
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps
virtual_mailbox_base = /var/mail/virtual
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000

# Which transport to use for each domain
transport_maps = mysql:/etc/postfix/mysql/transport_maps


/etc/postfix/mysql/relay_domains
~ Domains this mail server will relay (ie, send elsewhere)

user = myuser
password = mypassword
hosts = 127.0.0.1
dbname = mydatabase
query = SELECT domain FROM domains WHERE domain = '%s' and relay = 1 and enabled = 1

/etc/postfix/mysql/virtual_alias_domains
~ If you want to forward one domain to another domain, add the forwarding domain in the alias_domains table and add a route in the alias_maps table like @alias.com @goto.com.

user = myuser
password = mypassword
hosts = 127.0.0.1
dbname = mydatabase
query = SELECT domain FROM alias_domains WHERE domain = '%s' AND enabled = 1

/etc/postfix/mysql/virtual_alias_maps
~ User aliases eg mark@example.com goes to mark.long@example.com
~ Catchall: @example.com goes to mark.long@example.com
~ Nb. if you are using a domain that is not in the domains table, then you must add it to alias_domains table.

user = myuser
password = mypassword
hosts = 127.0.0.1
dbname = mydatabase
query = SELECT goto FROM alias_maps WHERE alias = '%s' AND enabled = 1

/etc/postfix/mysql/virtual_mailbox_domains
~ Virtual domains this mail server will handle

user = myuser
password = mypassword
hosts = 127.0.0.1
dbname = mydatabase
query = SELECT domain FROM domains WHERE domain = '%s' AND relay != 1 AND enabled = 1

/etc/postfix/mysql/virtual_mailbox_maps
~ Where to store a virtual mailbox's mail, prefixed by virtual_mailbox_base

user = myuser
password = mypassword
hosts = 127.0.0.1
dbname = mydatabase
query = SELECT maildir FROM mailboxes WHERE address = '%s' AND enabled = 1

/etc/postfix/mysql/transport_maps
~ What transport to use to send mail eg virtual or relay
~ Here you can put things like relay:[relay.mail-server.com] in the transport field

user = myuser
password = mypassword
hosts = 127.0.0.1
dbname = mydatabase
query = SELECT transport FROM domains WHERE domain = '%s'
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.