LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-03-2015, 09:13 AM   #1
eulaersi
LQ Newbie
 
Registered: Jul 2007
Posts: 27

Rep: Reputation: 0
Cannot send mail with postfix


I'm setting up a CentOS machine on Amazon EC2 that should be able to send me mails.

I've configured postfix so that it uses Amazon SES service. I was under the impression that everything worked.

When I restarted the EC2-instance, I cannot get mails working.

1) sudo service postfix shows that postfix is not working
-> how can I make sure that this service is always running?

2) in /var/log/maillog I notice:
Code:
Dec  3 15:07:06 ip-xx-xx-xxx-xxx postfix/cleanup[15610]: fatal: open lock file pid/unix.cleanup: cannot open file: Permission denied
Dec  3 15:07:07 ip-xx-xx-xxx-xxx postfix/master[15396]: warning: process /usr/libexec/postfix/cleanup pid 15610 exit status 1
Dec  3 15:07:07 ip-xx-xx-xxx-xxx postfix/master[15396]: warning: /usr/libexec/postfix/cleanup: bad command startup -- throttling
What can possible be wrong?
 
Old 12-04-2015, 08:14 PM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,691

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Centos 6 or 7?

If 6, the answer to your first question is chkconfig postfix on. If 7, systemctl enable postfix.
To start it up manually, sudo service postfix start or sudo systemctl start postfix.

Not sure what to do with your 2nd question. Does this appear when you shut the instance down or start it up? Will it go away once you solve question 1?
 
Old 12-04-2015, 08:15 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,025

Rep: Reputation: 67
I certainly hope that mail was sending correctly at one point. It's a crime how difficult it is to set up postfix on an EC2 instance.

How did you install postfix? Did you use a package manager? Did you compile/install from source?

I'm also wondering if maybe you fired up postfix before while you were logged in as root? This might result in postfix creating certain failes (like the pid/unix.cleanup file) with permissions that are not writable by anyone but root. In my experience (which includes some CentOS but much more Ubuntu), Postfix will run as its own user. On my Ubuntu machine where I installed using apt-get (same as yum on CentOS) then postfix runs as user postfix and I can see that in /var/lib/postfix, there appear to be a couple of files that relate to postfix operation.
 
Old 12-08-2015, 02:50 AM   #4
eulaersi
LQ Newbie
 
Registered: Jul 2007
Posts: 27

Original Poster
Rep: Reputation: 0
I did use a package manager. postfix is loaded as a service. But if I do "chkconfig postfix off" and reboot, and afterwards I start postfix manually, I still get these errors.

Code:
Dec  8 08:45:59 ip-xx-xx-xx-xx postfix/postfix-script[1511]: starting the Postfix mail system
Dec  8 08:45:59 ip-xx-xx-xx-xx postfix/master[1512]: daemon started -- version 2.6.6, configuration /etc/postfix
Dec  8 08:45:59 ip-xx-xx-xx-xx postfix/cleanup[1516]: fatal: open lock file pid/unix.cleanup: cannot open file: Permission denied
Dec  8 08:46:00 ip-xx-xx-xx-xx postfix/master[1512]: warning: process /usr/libexec/postfix/cleanup pid 1516 exit status 1
Dec  8 08:46:00 ip-xx-xx-xx-xx postfix/master[1512]: warning: /usr/libexec/postfix/cleanup: bad command startup -- throttling
 
Old 12-08-2015, 03:03 AM   #5
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,691

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by eulaersi View Post
I did use a package manager. postfix is loaded as a service. But if I do "chkconfig postfix off" and reboot, and afterwards I start postfix manually, I still get these errors.

Code:
Dec  8 08:45:59 ip-xx-xx-xx-xx postfix/postfix-script[1511]: starting the Postfix mail system
Dec  8 08:45:59 ip-xx-xx-xx-xx postfix/master[1512]: daemon started -- version 2.6.6, configuration /etc/postfix
Dec  8 08:45:59 ip-xx-xx-xx-xx postfix/cleanup[1516]: fatal: open lock file pid/unix.cleanup: cannot open file: Permission denied
Dec  8 08:46:00 ip-xx-xx-xx-xx postfix/master[1512]: warning: process /usr/libexec/postfix/cleanup pid 1516 exit status 1
Dec  8 08:46:00 ip-xx-xx-xx-xx postfix/master[1512]: warning: /usr/libexec/postfix/cleanup: bad command startup -- throttling
Searching the web for pid/unix.cleanup permission denied indicates that this might be an SELinux problem. On my system, unix.cleanup looks like this:
Code:
$ ls -Z /var/spool/postfix/pid
-rw-------. root root system_u:object_r:postfix_var_run_t:s0 master.pid
-rw-------. root root system_u:object_r:postfix_var_run_t:s0 unix.cleanup
You might want to check. Use restorecon to fix it if necessary.

For a quick check, you can temporarily set SELinux to permissive (setenforce permissive) and try restarting postfix.

Last edited by berndbausch; 12-08-2015 at 03:04 AM.
 
Old 12-08-2015, 11:24 AM   #6
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,025

Rep: Reputation: 67
Quote:
Originally Posted by eulaersi View Post
I did use a package manager. postfix is loaded as a service. But if I do "chkconfig postfix off" and reboot, and afterwards I start postfix manually, I still get these errors.

Code:
Dec  8 08:45:59 ip-xx-xx-xx-xx postfix/postfix-script[1511]: starting the Postfix mail system
Dec  8 08:45:59 ip-xx-xx-xx-xx postfix/master[1512]: daemon started -- version 2.6.6, configuration /etc/postfix
Dec  8 08:45:59 ip-xx-xx-xx-xx postfix/cleanup[1516]: fatal: open lock file pid/unix.cleanup: cannot open file: Permission denied
Dec  8 08:46:00 ip-xx-xx-xx-xx postfix/master[1512]: warning: process /usr/libexec/postfix/cleanup pid 1516 exit status 1
Dec  8 08:46:00 ip-xx-xx-xx-xx postfix/master[1512]: warning: /usr/libexec/postfix/cleanup: bad command startup -- throttling
How did you start postfix? Have you checked the permissions on the file pid/unix.cleanup?
 
Old 12-09-2015, 07:27 AM   #7
eulaersi
LQ Newbie
 
Registered: Jul 2007
Posts: 27

Original Poster
Rep: Reputation: 0
Tx for the reply. I'm almost there.

Mails are being sent when I set:
Code:
sudo setenforce 0
How should I solve this? I have no experience with SELinux.

Code:
$ ls -Z /var/spool/postfix/pid
-rw-------. root root unconfined_u:object_r:postfix_var_run_t:s0 master.pid
-rw-------. root root unconfined_u:object_r:var_run_t:s0 unix.bounce
-rw-------. root root unconfined_u:object_r:var_run_t:s0 unix.cleanup
-rw-------. root root unconfined_u:object_r:var_run_t:s0 unix.defer
-rw-------. root root unconfined_u:object_r:var_run_t:s0 unix.error
-rw-------. root root unconfined_u:object_r:var_run_t:s0 unix.local
-rw-------. root root unconfined_u:object_r:var_run_t:s0 unix.smtp
-rw-------. root root unconfined_u:object_r:var_run_t:s0 unix.trace
 
Old 12-09-2015, 07:59 AM   #8
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,691

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
var_run_t is wrong. This should fix it:

Code:
cd /var/spool/postfix/pid
chcon -t postfix_var_run_t *
The chcon command changes the file context, -t only changes the type; i.e. the part that ends in _t.

Since there might be other files with the wrong context, you can also do this:
Code:
restorecon -irv /var/spool/postfix
This will set the correct type for all files under /var/spool/postfix. -i ignores files that aren't there (otherwise, I presume, error messages might be issued), -r means recursive, and -v verbose.

Last edited by berndbausch; 12-09-2015 at 08:01 AM.
 
1 members found this post helpful.
Old 12-10-2015, 03:39 AM   #9
eulaersi
LQ Newbie
 
Registered: Jul 2007
Posts: 27

Original Poster
Rep: Reputation: 0
Tx for your replies.

[SOLVED]
 
  


Reply

Tags
amazon, postfix


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Can send mail but Not able to receive mail. Postfixadmin, dovecot, postfix setup RajeshThakur Linux - Newbie 9 04-20-2012 08:31 AM
[SOLVED] Postfix - I can send mail from my computer; but others can't send to me... djuhl30 Linux - Server 8 10-12-2009 02:34 PM
Postfix - allowing only certain users to send mail to a mail ID rahmathullakm Linux - Server 3 02-07-2009 11:05 AM
Postfix : mail cannot send to send outside ( can send/receive locally) bobbinsupport Linux - Networking 3 12-15-2007 10:40 PM
Postfix send mail problem(In RH9, kernal 2.4.20, postfix 2.1.5) minor Linux - General 4 07-11-2005 09:12 PM

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

All times are GMT -5. The time now is 03:13 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration