Not sure if this is mentioned already or not.. I tried to find but couldn't.. may be i missed it.

But the issue is:

I want two alias functionality:

1. when a mail is sent to an account; if it has a forwarder set; it should forward a copy of email to the mentioned email address.
2. all the emails sent to a domain alias should be automatically forwarded to the respective email account in the main domain.

eg for 1. =>
eg for 2. =>

We have a database that stores the mailboxes as we have our own control panel. I can get only one working at a time.

I have the mysql query in the .cf file and mentioned it in the as 'virtual_alias_maps' but i need both to work not just one at a time. Any solution or suggestion would be most appreciated.

Dani AI

Generated

Short answer: you can have both behaviours — per-account “copy-and-forward” and full domain-alias rewriting — by returning both destinations from Postfix’s alias lookup. Two practical ways that work with a MySQL backend are (A) combine two SQL maps with Postfix’s unionmap so results are concatenated, or (B) use a single SQL query that returns both the local mailbox and any forward addresses (UNION). virtual_alias_maps accepts multiple destinations (comma-separated) and Postfix has a lookup type that concatenates multiple map results. (postfix.org)

Example (use either approach A or B):

# main.cf
virtual_alias_maps = unionmap:{mysql:/etc/postfix/mysql_virtual_alias_maps.cf, mysql:/etc/postfix/mysql_domainalias_maps.cf}

When a lookup returns user@maindomain.com, hfg@gmail.com Postfix delivers locally and also forwards a copy. The unionmap:{...} form queries both maps and concatenates results. (postfix.org)

Example SQL (PostfixAdmin-style) for the domain-alias map (returns the target account for an alias domain):

# /etc/postfix/mysql_virtual_alias_domain_maps.cf (query=...)
query = SELECT goto
  FROM alias, alias_domain
 WHERE alias_domain.alias_domain = '%d'
   AND alias.address = CONCAT('%u','@',alias_domain.target_domain)
   AND alias.active = '1' AND alias_domain.active = '1'

That lets xyz@alias.com resolve to whatever xyz@maindomain.com has configured. (sources.debian.org)

Troubleshooting hints: test lookups with postmap -q 'user@domain' mysql:/path/to/map and verify virtual_alias_domains doesn’t appear in mydestination. Watch expansion_limit so queries that accidentally return many rows fail fast. Reload Postfix after changes and check mail logs for rewriting steps. (postfix.org)

Notes: — if you already store forward addresses in your goto column, ensure the map returns both addresses (local plus external). ’s pointer to a domain-alias walkthrough is on the right track; prefer the SQL + unionmap pattern or a single UNION query for cleaner, predictable results. (sources.debian.org)

can someone help me with this issue?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.