LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 12-08-2016, 11:52 AM   #1
jdehnert
LQ Newbie
 
Registered: Mar 2003
Location: Rohnert Park, CA, USA
Distribution: Red Hat
Posts: 4

Rep: Reputation: 0
Re-writing incoming Postfix


Greetings Everyone,

I m working on setting up a CentOS 7.2 host running Postfix 2.10 as a mail relay host to forward mail from things like printers and applications running on servers to our Exchange server running on office 365.

I have set up the host so that it does not deliver any mail locally, and I have it working when mail is sent from the mail relay host, but not when mail is is sent from another client to the relay host.

For local mail, the system connects to exchange and authenticates itself as a valid email user and passes the mail along. I have been trying to get postfix to rewrite the sender address on the mail envelope to the same valid email user so that when postfix connects, it will deliver all of the mail as if it were coming from my valid email user, but I am not having any luck getting this to work.

My idea is that if I can have all the mail sent to the mail relay forwarded roti the exchange server as if it were from the valid user, then when the relay host connects as the valid user, it will be able to send all the mail on to the end users.

I'm more than open to alternative methods and any suggestions.

Here is my latest postconf -n output

Some of these things might be left over from testing various methods of re-writing.

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debug_peer_list = smtp.office365.com
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_protocols = all
local_header_rewrite_clients = permit_mynetworks
local_recipient_maps =
local_transport = error:local mail delivery is disabled
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
message_size_limit = 20480000
mydestination =
myhostname = pet-mail-01.mydomain.com
mynetworks = cidr:/etc/postfix/mynets
myorigin = enphaseenergy.com
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
relayhost = [smtp.office365.com]:587
remote_header_rewrite_domain = mydomain.com
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sender_canonical_classes = envelope_sender,header_sender
sender_canonical_maps = hash:/etc/postfix/sender_canonical_maps
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_generic_maps = hash:/etc/postfix/generic
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/smtp_sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_ciphers = export
smtp_tls_mandatory_ciphers = high
smtp_tls_protocols = !SSLv2, !SSLv3
smtp_tls_security_level = encrypt
smtp_use_tls = yes
unknown_local_recipient_reject_code = 550


and here are the contents of my supporting files:

header_checks
#/^From:.*/ From:kemail@mydomain.com

sender_canonical_maps
#@/.+/ kemail@mydomain.com
@mydomain.com kemail@mydomain.com


smtp_sasl_passwd
# foo.com usernameassword
[smtp.office365.com]:587 kemail@mydomain.comassword


transport
mydomain.com smtp:[smtp.office365.com]:587

At this link, (http://pastebin.com/7ju7dDYc) is a copy of the log output when postfix tried to forward mail from a host it-lnx-03, to my yahoo mail account.
 
Old 12-08-2016, 12:22 PM   #2
c0wb0y
Member
 
Registered: Jan 2012
Location: Inside the oven
Distribution: Windows
Posts: 421

Rep: Reputation: 74
You probably want 'smtp_header_checks'?
 
Old 12-08-2016, 02:16 PM   #3
jdehnert
LQ Newbie
 
Registered: Mar 2003
Location: Rohnert Park, CA, USA
Distribution: Red Hat
Posts: 4

Original Poster
Rep: Reputation: 0
Here is the postfix rewriting overview:

http://d.pr/i/Inmc/20WXgUSE

Should I be using the trivial rewrite to change the envelope address?

I'm reading through the documents, but I haven't quite figured out how to make the rewrite work yet. If anyone has any examples, I would live to see them.
 
Old 12-10-2016, 05:35 PM   #4
c0wb0y
Member
 
Registered: Jan 2012
Location: Inside the oven
Distribution: Windows
Posts: 421

Rep: Reputation: 74
I re-read your post and I came up with a different idea.

Quote:
I have set up the host so that it does not deliver any mail locally, and I have it working when mail is sent from the mail relay host, but not when mail is is sent from another client to the relay host.
So a local user is able to sent email to the Exchange server? But not a relayed email coming from, say printer or other sources?

How about you make the local user as recipient of all the mails from printers et al then forward that to Exchange server? That could be accomplised using virtual_alias_maps. For example:

Code:
localaccount@relaymailserver.com   auser@myexchangeserver.com

Last edited by c0wb0y; 12-11-2016 at 11:39 AM.
 
  


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 incoming mail from internet finsh Linux - Server 3 12-23-2014 10:44 PM
Postfix rejecting incoming mail BeauSanders Linux - General 1 10-12-2012 11:18 PM
postfix incoming mail problem punker22 Linux - Networking 1 07-17-2004 12:45 AM
Postfix should do more than delete any incoming mail, right? icarus24 Linux - Networking 12 01-05-2004 09:11 PM
Postfix Problem - No incoming mail Gareman Linux - Networking 4 02-10-2003 11:40 AM

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

All times are GMT -5. The time now is 10:45 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
Open Source Consulting | Domain Registration