# cannot open /etc/mail/mailer.conf, using /usr/libexec/sendmail/sendmail as default MT



## sjap (Dec 29, 2011)

Hi,

When I try to send a mail from postfix-current-2.9.20111219,4 I get this error in my maillog:

```
Dec 29 13:36:13 garfield mailwrapper[94442]: cannot open /etc/mail/mailer.conf, using /usr/libexec/sendmail/sendmail as default MTA
Dec 29 13:36:13 garfield sendmail[94442]: NOQUEUE: SYSERR(UID80): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
Dec 29 13:36:13 garfield mailwrapper[94443]: cannot open /etc/mail/mailer.conf, using /usr/libexec/sendmail/sendmail as default MTA
Dec 29 13:36:13 garfield sendmail[94443]: NOQUEUE: SYSERR(UID80): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
```

I have checked the files permission:


```
garfield ~ # ls -lh /etc/mail/mailer.conf
-rw-r--r--  1 root  wheel   212B Oct 21 12:11 /etc/mail/mailer.conf
garfield ~ # ls -lh /etc/mail/sendmail.cf
-rw-r--r--  1 root  wheel    57K Dec  5 19:18 /etc/mail/sendmail.cf
```

I'm running FreeBSD 8.2-p5. Hope you guys can help me.


----------



## sjap (Dec 31, 2011)

Is there really no one who can help me?


----------



## SirDice (Jan 2, 2012)

A lot of people have been celebrating Christmas and New-years, have some patience.

What does /etc/mail/mailer.conf contain?


----------



## amilojko (Jan 2, 2012)

Why are your running postfix and sendmail? Does the file /etc/mail/mailer.conf exist? What are the permissions of the file? What user does sendmail run under? How did you install sendmail? How did you install postfix? What is the contents of your /etc/rc.conf file? What's running on port 25?


----------



## sjap (Jan 3, 2012)

Thanks for your answer 

My /etc/mail/mailer.conf contains:


```
#
# Execute the Postfix sendmail program, named /usr/local/sbin/sendmail
#
sendmail        /usr/local/sbin/sendmail
send-mail       /usr/local/sbin/sendmail
mailq           /usr/local/sbin/sendmail
newaliases      /usr/local/sbin/sendmail
```

In my /etc/rc.conf I have this:


```
# Mail
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
daily_clean_hoststat_enable="NO"
daily_status_mail_rejects_enable="NO"
daily_status_include_submit_mailq="NO"
daily_submit_queuerun="NO"
postfix_enable="YES"
```

Should sendmail not be disbaled in my rc.conf?


----------



## amilojko (Jan 4, 2012)

Interesting.
Did you restart the server?

Both files you have look good to me.
Sendmail and Postfix should not run at the same time. rc.conf looks good.
I suppose you could run them on alternate ports (never tried this myself).
This is happening when you are sending mail from the console right?
Are ok when you are doing SMTP?
How did you install postfix? From ports?
This also could be an issue with postfix configuration and you may have to reinstall or maybe you haven't built all the utilities that come with postfix.
I've never built postfix from source, but with sendmail you have to build sendmail utilities as well mail, mail.local, vacation, praliases etc...
Does the file /usr/local/sbin/sendmail exist?

Also should it not be /usr/sbin/sendmail? Check that file too.


----------



## SirDice (Jan 4, 2012)

If I read Postfix's pkg-messsage correctly /etc/mail/mailer.conf should not be edited. Restore it to it's original state and try again.


----------



## kpa (Jan 4, 2012)

Check that /usr/sbin/sendmail is a symbolic link to /usr/sbin/mailwrapper.


----------



## sjap (Jan 4, 2012)

Yes, This is very intereseted. 

Jup, i have rebooted the server without any luck. I have installed postfix from ports.

It's happing when i try to send a mail from apache which are installed on the server also.

I have also tried to install postfix-2.7.7,1 instead of postfix_current. Without any luck 



```
garfield ~ # file /usr/sbin/sendmail
/usr/sbin/sendmail: symbolic link to `/usr/sbin/mailwrapper'
```



```
garfield ~ # file /usr/local/sbin/sendmail
/usr/local/sbin/sendmail: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.2, not stripped
```


----------



## sjap (Jan 4, 2012)

I have now tried to restore my /etc/mail/mailer.conf to:


```
# $FreeBSD: src/etc/mail/mailer.conf,v 1.3.36.1.6.1 2010/12/21 17:09:25 kensmith Exp $
#
# Execute the "real" sendmail program, named /usr/libexec/sendmail/sendmail
#
sendmail        /usr/libexec/sendmail/sendmail
send-mail       /usr/libexec/sendmail/sendmail
mailq           /usr/libexec/sendmail/sendmail
newaliases      /usr/libexec/sendmail/sendmail
hoststat        /usr/libexec/sendmail/sendmail
purgestat       /usr/libexec/sendmail/sendmail
```

But i stil got an error when i try to send a mail.


```
Jan  4 11:48:37 garfield mailwrapper[18440]: cannot open /etc/mail/mailer.conf, using /usr/libexec/sendmail/sendmail as default MTA
Jan  4 11:48:37 garfield sendmail[18440]: NOQUEUE: SYSERR(UID80): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
Jan  4 11:48:37 garfield mailwrapper[18441]: cannot open /etc/mail/mailer.conf, using /usr/libexec/sendmail/sendmail as default MTA
Jan  4 11:48:37 garfield sendmail[18441]: NOQUEUE: SYSERR(UID80): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
```


----------



## SirDice (Jan 4, 2012)

What are the permissions on /etc/mail/ and /etc/mail/mailer.conf?


----------



## sjap (Jan 4, 2012)

```
drwxr-xr-x  2 root  wheel      1024 Jan  4 12:47 mail
-rw-r--r--  1 root  wheel  450 Jan  4 12:47 /etc/mail/mailer.conf
```


----------



## amilojko (Jan 5, 2012)

OK, sjap,

If you are trying to send mail from Apache you probably mean from PHP this nothing do to with sendmail or postfix. If you can send mail from the command line and you can send mail from MUA via SMTP your MTA installation is proper. If you've got Apache problems this is a different can of worms and requires a different set of questions. I'm asking more questions than I'm answering.

How are you trying to send mail from Apache? What does your php.ini (/usr/local/lib/php.ini) look like? Show the PHP code you are using to send mail.

In order to send mail from Apache/PHP you have to make sure user www is trusted and always use -f switch for the mail() function in PHP. My first guess here is your php.ini mail program is set to sendmail.


----------



## sjap (Jan 6, 2012)

My php code look like this:


```
<?php
$to = 'mail';
$subject = 'Test email';
$message = "Hello World!\n\nThis is my first mail.";
$headers = "From: mail\r\nReply-To: mail";
$mail_sent = @mail( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed";
?>
```

But I can't send mail from the command line from the server. I get the same error as I posted previously in this thread.


----------



## amilojko (Jan 7, 2012)

OK use -f

```
mail($TO, $subject, $body, $headers, "-f $returnaddr")
```
But if you can't send mail from command line then this is not the problem.

I just installed posftix from mail/postfix 2.8.0_1 and it works just fine out of the box. Just changed main.cf to masquarade.

```
backup# cat mailer.conf
#
# Execute the Postfix sendmail program, named /usr/local/sbin/sendmail
#
sendmail        /usr/local/sbin/sendmail
send-mail       /usr/local/sbin/sendmail
mailq           /usr/local/sbin/sendmail
newaliases      /usr/local/sbin/sendmail
backup#
backup# uname -a
FreeBSD backup 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC
backup# file /usr/local/sbin/sendmail
/usr/local/sbin/sendmail: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.2, not stripped
backup#
backup# file /usr/sbin/mailwrapper
/usr/sbin/mailwrapper: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.2, stripped
backup# file /usr/sbin/sendmail
/usr/sbin/sendmail: symbolic link to `/usr/sbin/mailwrapper'
backup# ls -l /usr/local/sbin/sendmail; ls -l /usr/sbin/sendmail; ls -l /usr/sbin/mailwrapper
-rwxr-xr-x  1 root  wheel  200215 Jan  6 23:50 /usr/local/sbin/sendmail
lrwxr-xr-x  1 root  wheel  21 Feb 17  2011 /usr/sbin/sendmail -> /usr/sbin/mailwrapper
-r-xr-xr-x  1 root  wheel  6164 Feb 17  2011 /usr/sbin/mailwrapper
```


```
backup# cat /etc/passwd
# $FreeBSD: src/etc/master.passwd,v 1.40.22.1.6.1 2010/12/21 17:09:25 kensmith Exp $
#
root:*:0:0:Charlie &:/root:/bin/csh
toor:*:0:0:Bourne-again Superuser:/root:
daemon:*:1:1:Owner of many system processes:/root:/usr/sbin/nologin
operator:*:2:5:System &:/:/usr/sbin/nologin
bin:*:3:7:Binaries Commands and Source:/:/usr/sbin/nologin
tty:*:4:65533:Tty Sandbox:/:/usr/sbin/nologin
kmem:*:5:65533:KMem Sandbox:/:/usr/sbin/nologin
games:*:7:13:Games pseudo-user:/usr/games:/usr/sbin/nologin
news:*:8:8:News Subsystem:/:/usr/sbin/nologin
man:*:9:9:Mister Man Pages:/usr/share/man:/usr/sbin/nologin
sshd:*:22:22:Secure Shell Daemon:/var/empty:/usr/sbin/nologin
smmsp:*:25:25:Sendmail Submission User:/var/spool/clientmqueue:/usr/sbin/nologin
mailnull:*:26:26:Sendmail Default User:/var/spool/mqueue:/usr/sbin/nologin
bind:*:53:53:Bind Sandbox:/:/usr/sbin/nologin
proxy:*:62:62:Packet Filter pseudo-user:/nonexistent:/usr/sbin/nologin
_pflogd:*:64:64:pflogd privsep user:/var/empty:/usr/sbin/nologin
_dhcp:*:65:65:dhcp programs:/var/empty:/usr/sbin/nologin
uucp:*:66:66:UUCP pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp/uucico
pop:*:68:6:Post Office Owner:/nonexistent:/usr/sbin/nologin
www:*:80:80:World Wide Web Owner:/nonexistent:/usr/sbin/nologin
nobody:*:65534:65534:Unprivileged user:/nonexistent:/usr/sbin/nologin
cyrus:*:60:60:the cyrus mail server:/nonexistent:/usr/sbin/nologin
postfix:*:125:125:Postfix Mail System:/var/spool/postfix:/usr/sbin/nologin
backup#
```

SYSERROR(UID80) means you www user is trying to send mail. These errors look like they are all from Apache. Is this correct? When you send mail from command line there should be a different UID.


----------



## sjap (Jan 8, 2012)

I'm still getting 


```
Jan  8 12:12:51 garfield mailwrapper[41487]: cannot open /etc/mail/mailer.conf, using /usr/libexec/sendmail/sendmail as default MTA
Jan  8 12:12:51 garfield sendmail[41487]: NOQUEUE: SYSERR(UID80): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
```

When I try to use the -f option in my php code.

It's really weird I have installed FreeBSD many times with postfix and apache but I have never been exposed to something like this. Maybe I should upgrade to Freebsd 9.0 and see if that resolves my problem.


----------



## amilojko (Jan 9, 2012)

Perhaps removing postfix and getting the new port version and then installing it from ports again. Try that first, maybe that port is screwed up. Go with the new 2.8.0.

Good luck.


----------



## sjap (Jan 11, 2012)

I have tried with 2.9.20120102,4


----------



## Abriel (Jan 12, 2012)

I tested your script, it works on my FreeBSD 7.3 with postfix, but it does not use mailwrapper and sendmail.

[CMD="postconf -d"]| grep mail_version[/CMD]

```
mail_version = 2.8.7
```

[CMD="cat"]/etc/periodic.conf[/CMD]

```
daily_clean_hoststat_enable="NO"
daily_status_mail_rejects_enable="NO"
daily_status_include_submit_mailq="NO"
daily_submit_queuerun="NO"
```

[CMD="cat"]/etc/rc.conf | grep sendmail[/CMD]

```
sendmail_enable="NONE"
sendmail_flags="-bd"
sendmail_pidfile="/var/spool/postfix/pid/master.pid"
sendmail_outbound_enable="NO"
sendmail_submit_enable="NO"
sendmail_msp_queue_enable="NO"
```

And, I found 


> ```
> sendmail_enable="NO"
> This disables _only_ the ``inbound Sendmail daemon''.
> 
> ...


----------



## sjap (Jan 15, 2012)

Thanks. 
I'll try it next time i can reboot the server.


----------



## sjap (Jan 21, 2012)

I have now rebooted my server and set 
	
	



```
sendmail_enable="NONE"
```
 in rc.conf. But I still get errors in my maillog;


```
Jan 21 14:15:45 garfield mailwrapper[6652]: cannot open /etc/mail/mailer.conf, using /usr/libexec/sendmail/sendmail as default MTA
Jan 21 14:15:45 garfield sendmail[6652]: NOQUEUE: SYSERR(UID80): /etc/mail/sendmail.cf: line 0: cannot open: Permission denied
```

I have also upgraded from 8.2 to 9.0 without any luck


----------

