LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 07-18-2019, 07:05 AM   #1
LamerMmc
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Rep: Reputation: Disabled
postfix is sending cron mails to relayhost on CentOS


Hey there,

the cronjobs on my CentOS server are sending mails to root@hostname.domain due

Code:
MAILTO=root
in /etc/crontab.
And this is good so.
I want to keep these mails on the server, but my postfix is sending these to the relayhost.
How to prevent postfix to sending these mails. normal mails which will be send manually or by script should work.

My main.cf is quite standard. I just changed the relayhost value to send the mails to the relayserver.
Code:
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
dta_directory = /var/lib/postfix
mail_owner = postfix
myorigin = server.domain.com
inet_interfaces = loopback-only
inet_protocols = ipv4
mydestination =
local_transport = error: local delivery disabled
unknown_local_recipient_reject_code = 550
relay_domains = $mydestination
relayhost = 10.10.10.10
recipient_canonical_classes = envelope_recipient, header_recipient
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
Can somebody help to keep these mails locally?
 
Old 07-18-2019, 08:55 AM   #2
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
I don't know postfix, but have you tried
Code:
MAILTO=root@localhost
?

If that doesn't work, check this.
 
Old 07-18-2019, 09:23 AM   #3
LamerMmc
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
I don't know postfix, but have you tried
Code:
MAILTO=root@localhost
?

If that doesn't work, check this.
Hi,

I also tried this.
But my issue not even for mails from cron, but also all mails to user@hostname.domain
 
Old 07-18-2019, 10:20 AM   #4
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by LamerMmc View Post
Hi,

I also tried this.
But my issue not even for mails from cron, but also all mails to user@hostname.domain
1. did changing the MAILTO in cron fix that problem?
2. what? "all emails to..." is not a question. What is the new problem?
 
Old 07-18-2019, 10:40 AM   #5
LamerMmc
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
1. did changing the MAILTO in cron fix that problem?
2. what? "all emails to..." is not a question. What is the new problem?
1. did not fix the Problem
2. its not a question and there is no new problem.

I just want that all mails to user@hostname.domain not send out via postfix to relayhost.
 
Old 07-18-2019, 11:00 AM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by LamerMmc View Post
1. did not fix the Problem
2. its not a question and there is no new problem.

I just want that all mails to user@hostname.domain not send out via postfix to relayhost.
Only one user? Or all users at that domain address?
Where do you want the emails to go if not to your relayhost?
 
Old 07-18-2019, 11:07 AM   #7
LamerMmc
LQ Newbie
 
Registered: Jul 2019
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by scasey View Post
Only one user? Or all users at that domain address?
Where do you want the emails to go if not to your relayhost?
all users. everything that matches user@hostname.domain as recipient.

local mail space. (via command 'mail')

everything else schould be send out as normal.
 
Old 07-18-2019, 02:34 PM   #8
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,725

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
With qmail, we'd manage that with aliases.
Try searching for something like "postfix alias" or see man 5 aliases
 
  


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 relayhost configuration (SMTPS) rutgerw Linux - Server 3 02-19-2011 02:02 AM
[SOLVED] Postfix relayhost not working, if domain hosted on same server, but MX points outside katru Linux - Server 2 06-23-2010 06:25 PM
postfix - relayhost configuration problem kalinic Ubuntu 20 03-02-2009 03:36 AM
Postfix relayhost or direct deliver john.dixon Linux - Server 2 10-30-2008 08:44 AM
postfix relayhost gabsik Linux - Networking 1 02-08-2007 02:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:26 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