LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-03-2016, 09:50 AM   #1
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Postfix: relay mail for unknown user


I don't know if relaying is the proper term, so forgive me.

I'm playing around with a home email server with virtual users, using postfix and dovecot.

What happens, is if I try to send an email to a virtual user that does not exist on the server, the email is rejected. What I would like to happen, is, if that user does not exist the email is passed on to another server.

Can this be done with postfix? I've looked at fallback_transport and fallback_relay as suggested by some duckduckgo-ing with no success.

I'd appreciate a nudge in the right direction, rather than the complete solution (I could always come back later if I can't get it on my own).

TIA
 
Old 09-03-2016, 10:55 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
What I would like to happen, is, if that user does not exist the email is passed on to another server.
Have a look at the luser_relay
 
Old 09-04-2016, 02:10 AM   #3
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335

Original Poster
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
I'd looked into luser_relay, and unless I'm misunderstanding, it's not what I want.

Unfortunately, re-reading my post, maybe it's not as clear as I'd like. Let me give an example in the hopes it is clear.

I have a virtual user setup, with a PostgreSQL back end. So, it has tables for domains, users and aliases as is typical. Username is the full email address (user@domain).

I send an email to "goumba@example.net". This user is not one of the users on this particular server. Postfix looks, finds example.net, but no such user on the server. The email is bounced.

What I would like it to do now is instead of bouncing that email, is submit it to another SMTP server (be it postfix or whatever), untouched, as if it was being submitted through that server initially. Same exact username, etc.

So,
Code:
email to goumba@example.org -> submit to postfix -> not found -> submit to smtp.exampleserver2.net
I hope I've better described my desire this time.

Last edited by goumba; 09-04-2016 at 02:12 AM.
 
Old 09-04-2016, 10:43 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
What I would like it to do now is instead of bouncing that email, is submit it to another SMTP server (be it postfix or whatever), untouched, as if it was being submitted through that server initially. Same exact username, etc.
This is what luser_relay does. From this
Quote:
When the local(8) delivery agent finds that a message recipient does not exist, the message is normally returned to the sender ("user unknown"). Sometimes it is desirable to forward mail for non-existing recipients to another machine. For this purpose you can specify an alternative destination with the luser_relay configuration parameter.
 
1 members found this post helpful.
Old 09-05-2016, 08:49 AM   #5
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335

Original Poster
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Right, but I don't wish to transform the destination address in any form. In other words, no address rewriting.

So, say if I use

Code:
luser_relay = $user@exampleserver2.net
my username of xxxx@example.net becomes xxxx@exampleserver2.net. This is not what I want. I would like it to remain xxxx@example.net.

My use case is a little, err, odd: like I said this is just to get myself learning the postfix, dovecot, virtual user set up. I must admit, I hadn't posted this all earlier as I was avoiding describing the case as I was expecting, knowing people, rather than try to help, I would get a "WHY ARE YOU DOING THIS?" and no help.

Basically, here goes.

I set up postfix + dovecot for mail delivery locally and sending with virtual users. These users are actually a few of my off site email addresses, using getmail and postfix+lmtp to store copies locally. This works. The problem is actually because of a bit of a clash of domains.

I have an account, goumbaxx@gmail.com. A friend sends me an email to goumba@example.net. I wish to reply. His address is dudexx@gmail.com.

I send the email, and postfix looks in the pgSQL database of domains, finds gmail. Great. It should as it needs to do so to deliver MY mail locally.

It now looks up dudexx@gmail.com. BAM! Can't find it. Duh, not 'hosted' my on mail server. So, the email rightfully gets bounced.

gmail.com is not in mydestination, or other configuration directives in main.cf. The only place it is mentioned is in that pgSQL table.

What I would like to happen, just for the purposes of my use case, is to say 'ok, it's not here, now send it, exactly as is, to mail.example.net (not gmail's smtp, but that of my sending address) to be delivered. NO address writing or manipulation of the original email. I thought I understood fallback_transport to be a use for this along with local_recipient_maps = but it still bounces.

Relevant from log:
Code:
Sep  5 11:47:33 mail dovecot: lmtp(2461): Connect from local
Sep  5 11:47:33 mail postfix/lmtp[2632]: 386296C9599: to=<dudexx@gmail.com>, relay=mail[private/dovecot-lmtp], delay=0.41, delays=0.29/0.05/0/0.07, dsn=5.1.1, status=bounced (host mail[private/dovecot-lmtp] said: 550 5.1.1 <dudexx@gmail.com> User doesn't exist: dudexx@gmail.com (in reply to RCPT TO command))
Sep  5 11:47:33 mail dovecot: lmtp(2461): Disconnect from local: Successful quit
Sep  5 11:47:33 mail postfix/cleanup[2625]: 927EA6C95AA: message-id=<20160905154733.927EA6C95AA@mail>
Sep  5 11:47:33 mail postfix/bounce[2633]: 386296C9599: sender non-delivery notification: 927EA6C95AA
Sep  5 11:47:33 mail postfix/qmgr[2620]: 927EA6C95AA: from=<>, size=2126, nrcpt=1 (queue active)

Last edited by goumba; 09-05-2016 at 10:52 AM. Reason: Some more clarification.
 
Old 09-05-2016, 12:26 PM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
gmail.com is not in mydestination, or other configuration directives in main.cf. The only place it is mentioned is in that pgSQL table.
Ok I understand it's for learning purposes, but why put gmail.com into virtual domains. You should leave it apart, so postfix uses dns to find the correct MX host for gmail.com and deliver the email to it.
Re, your gmail account, you can setup forwarding to you local account.

Anyways, I've not tried anything similar, but perhaps you may give this a try.

Regards
 
1 members found this post helpful.
Old 09-05-2016, 04:00 PM   #7
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335

Original Poster
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Quote:
Originally Posted by bathory View Post
Ok I understand it's for learning purposes, but why put gmail.com into virtual domains.
First thing I tried was removing it, and once I did postfix+lmtp stopped delivering mail locally to any affected account using that domain.

Quote:
Re, your gmail account, you can setup forwarding to you local account.
I know. The problem is not with my gmail account. It's with sending an email from the example.net account (which isn't really the domain name, the real domain is my personal domain) to a gmail account because of this set up.

Meh, thanks for your help. It seems this is something that can not be worked around. Thank you for your patience.

Last edited by goumba; 09-05-2016 at 04:02 PM.
 
Old 09-17-2018, 04:13 AM   #8
akiuni
Member
 
Registered: Sep 2012
Location: France
Distribution: debian
Posts: 56

Rep: Reputation: Disabled
Hello

(I know this is an old post, my answer is more about guys facing the same issue today)

Maybe you could think your problem in a different way, if you know the "local" users you can create a virtual alias for them a redirect the other to your gateway.

For example :

In main.cf, remove your destination domain (example.net) from mydestination and create a virtual aliases map :
Code:
myorigin = $mydomain
mydestination = localhost.local, localhost
virtual_alias_maps = hash:/etc/postfix/virtual
In your virtual alias map, redirect all your users to localhost :
Code:
cat > /etc/postfix/virtual <<_EOF_
user1     user1@localhost
user2     user2@localhost
_EOF_
create the db file and reload postfix :
Code:
postmap /etc/postfix/virtual
postfix reload
This way, all the emails to user1@example.net and user2@example.net will be delivered localy and those for user3@example.net will be sent to the relay host.
 
Old 06-06-2020, 12:27 PM   #9
eemarc
LQ Newbie
 
Registered: Jun 2020
Posts: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by akiuni View Post
Hello

(I know this is an old post, my answer is more about guys facing the same issue today)

Maybe you could think your problem in a different way, if you know the "local" users you can create a virtual alias for them a redirect the other to your gateway.

For example :

In main.cf, remove your destination domain (example.net) from mydestination and create a virtual aliases map :
Code:
myorigin = $mydomain
mydestination = localhost.local, localhost
virtual_alias_maps = hash:/etc/postfix/virtual
In your virtual alias map, redirect all your users to localhost :
Code:
cat > /etc/postfix/virtual <<_EOF_
user1     user1@localhost
user2     user2@localhost
_EOF_
create the db file and reload postfix :
Code:
postmap /etc/postfix/virtual
postfix reload
This way, all the emails to user1@example.net and user2@example.net will be delivered localy and those for user3@example.net will be sent to the relay host.
Usually you use the full email address like "user1@example.net".

"example.net" must be specified in "main.cf" as virtual domain: "virtual_mailbox_domains = example.net", otherwise the virtual alias map would be ignored.

Then you have still the same problem.
 
  


Reply



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
[POSTFIX] User Unknown in Virtual Alias Table Error - Unable to Forward Mail to Gmail DevAndy Linux - Server 4 01-01-2014 06:28 PM
Configure Postfix to relay mail to multiple internal mail servers w/different domains tristopherr Linux - Server 2 05-08-2011 06:23 AM
Postfix 2.8.2 rejecting some mail with user unknown KamasCZ Linux - Server 1 04-22-2011 08:34 AM
Postfix user@domain restricted mail relay configuration bntawil Linux - Server 1 07-22-2008 05:35 PM
Postfix as a mail relay (getting relay access denied) hypexr Linux - Software 3 09-13-2005 07:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:17 PM.

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
Open Source Consulting | Domain Registration