# mail



## ajbrehm (Jun 6, 2021)

I noticed that the mail command doesn't work, that is does not send mails or see sent mails.

Have I missed some configuration during the install? I expected it just to work locally like it did with NetBSD.

I.e. mail root and a subject and some text does not send a mail to root and neither does it work between other users. I am not talking about network mail, just local.

What am I doing wrong?


----------



## SirDice (Jun 6, 2021)

Did you perhaps disable sendmail during the install?


----------



## ajbrehm (Jun 6, 2021)

Just did a plain install without settings anything (except timezone and root password) and mail doesn't work.

Why would sendmail be needed for local mail? I thought sendmail was for sending mail to other hosts?

Anyway, I tried enabling sendmail on another FreeBSD VM and after a reboot local mail still didn't work.


----------



## ajbrehm (Jun 6, 2021)

For sendmail to work I had to add the hostname to /etc/hosts. Maybe this was done by the installer on NetBSD and that's why it worked there.

I hope that was the only issue that was causing this behavious.


----------



## SirDice (Jun 6, 2021)

ajbrehm said:


> Why would sendmail be needed for local mail?


How do you think mail works?


ajbrehm said:


> For sendmail to work I had to add the hostname to /etc/hosts.


Shouldn't be needed, but it does beg the question, did you set a hostname in /etc/rc.conf?


----------



## ajbrehm (Jun 6, 2021)

SirDice said:


> How do you think mail works?



I wasn't sure. I thought local mail might be written directly into mailbox files. I thought sendmail was for sending mail to other hosts.



SirDice said:


> Shouldn't be needed, but it does beg the question, did you set a hostname in /etc/rc.conf?



I did, yes.

Anyway, it works now. Ta.


----------



## im (Jun 6, 2021)

I have a possibility to check local mail on default install of 'FreeBSD 11.1-RELEASE'.

On my machine the local mail works without any customization, except setting the hostname. Also I have active internet connection with configured DNS.

how it works, example:

```
admin@g9:~ % mail -s test root
test local mail for root
.
EOT
admin@g9:~ % su -
Password:
root@g9:~ # mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/root": 1 message 1 new
>N  1 admin@g9.com  Sun Jun  6 22:15  19/817   "test"
&
Message 1:
From admin@9.com Sun Jun  6 22:15:12 2021
Date: Sun, 6 Jun 2021 22:15:12 +0300 (EEST)
From: Admin Adminenko <admin@g9.com>
To: root@g9.com
Subject: test

test local mail for root

& q
Saved 1 message in mbox
```

When sendmail stopped using `/etc/rc.d/sendmail forcestop` then local delivery fails.
/var/log/maillog

```
Jun  6 22:29:00 green9 sendmail[75638]: 156JT0xA075638: from=admin, size=31, class=0, nrcpts=1, msgid=<202106061929.156JT0xA075638@g9.com>, relay=admin@localhost
Jun  6 22:29:00 green9 sendmail[75638]: 156JT0xA075638: to=root, ctladdr=admin (1001/1001), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30031, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
```


----------

