This thread is dedicated to simple command line tools as mail client for normal desktop users, in order
to show that FreeBSD has a past and a future as desktop system.
My contribution is to configure
I will configure
improvements are welcome. I hope, I will not offend those that want to mutilate FreeBSD MTA support to their needs.
I just want to show how easy is to configure
Sendmail does not support OAuth, you need to enable less secure apps in your gmail account.
Google will disable them after a while if you do not use them. For that, login into https://www.google.com and
visit: https://myaccount.google.com/lesssecureapps
Now, the configuration of
We need sendmail compiled with cyrussasl support. Do first:
# pkg install cyrus-sasl
Then recompile
https://docs.freebsd.org/en_US.ISO8859-1/books/handbook/SMTP-Auth.html
namely:
# cat > /etc/make.conf
SENDMAIL_CFLAGS=-I/usr/local/include/sasl -DSASL
SENDMAIL_LDADD=/usr/local/lib/libsasl2.so
^D
# cd /usr/src/lib/libsmutil
# make cleandir && make obj && make
# cd /usr/src/lib/libsm
# make cleandir && make obj && make
# cd /usr/src/usr.sbin/sendmail
# make cleandir && make obj && make && make install
In this text, myhostname is to be always replaced by the output
of `hostname -f`. Put it also in /etc/hosts as something like:
127.0.0.1 localhost myhostname
::1 localhost myhostname
New /etc/mail/freebsd.mc as follows, back up the old:
**1: myhostname must be substituted with the output of `hostname -f`.
**2: "smtp.gmail.com" must be the smtp server
**3: here goes the port of the smtp server using tls / starttls.
This configuration needs that the following files be created:
(1) /etc/mail/local-host-names
It contains the domains considered local in separated lines, here:
localhost
myhostname
where myhostname is the output of `hostname -f`
(2) /etc/mail/genericstable
It contains a mapping from local email addresses to the ones passed
to the smtp server in "From header" and envelope, here the only line:
@myhostname mygooglename@gmail.com
where myhostname is the output of `hostname -f`
(3) Do first "
/etc/mail/auth/client contains the name of the smtp server, your
username there and password there, here:
AuthInfo:smtp.gmail.com "U:mygooglename@gmail.com" "P:mygooglepass"
After creating the files do:
# cd /etc/mail
# makemap hash genericatable < genericstable
# chmod 700 /etc/mail/auth
# cd /etc/mail/auth
# makemap hash client < client
# chmod 600 client client.db
# cd ..
(after any change of genericstable or auth/client run the corresponding makemap that generates .db files)
After every configuration, do the following in /etc/mail to make it active:
# rm myhostname.mc myhostname.cf (myhostname is output of `hostname -f`)
# make cf
# make install
# make restart
Then test sending a mail with:
# mail emailaddress
or verbose:
# mail -v emailaddress
--
Sources:
(1) In /usr/share/sendmail/cf/README :
"SMTP AUTHENTICATION ->
Providing SMTP AUTH Data when sendmail acts as Client"
(2) http://www.sendmail.org/~ca/email/auth.html#authconf
(3) /usr/share/doc/smm/08.sendmailop/paper.ascii.gz
Page 66, AuthOptions
(4) https://docs.oracle.com/cd/E37670_01/E41138/html/ch15s06.html
to show that FreeBSD has a past and a future as desktop system.
My contribution is to configure
sendmail
as smart host, in order that one can use normal mail
to send mails. Perhaps someone can follow with fetchmail
?I will configure
sendmail
with gmail, but better you use other provider. I am not an expert, hence, corrections andimprovements are welcome. I hope, I will not offend those that want to mutilate FreeBSD MTA support to their needs.
I just want to show how easy is to configure
sendmail
.Sendmail does not support OAuth, you need to enable less secure apps in your gmail account.
Google will disable them after a while if you do not use them. For that, login into https://www.google.com and
visit: https://myaccount.google.com/lesssecureapps
Now, the configuration of
sendmail
.We need sendmail compiled with cyrussasl support. Do first:
# pkg install cyrus-sasl
Then recompile
sendmail
according to item 4 in:https://docs.freebsd.org/en_US.ISO8859-1/books/handbook/SMTP-Auth.html
namely:
# cat > /etc/make.conf
SENDMAIL_CFLAGS=-I/usr/local/include/sasl -DSASL
SENDMAIL_LDADD=/usr/local/lib/libsasl2.so
^D
# cd /usr/src/lib/libsmutil
# make cleandir && make obj && make
# cd /usr/src/lib/libsm
# make cleandir && make obj && make
# cd /usr/src/usr.sbin/sendmail
# make cleandir && make obj && make && make install
In this text, myhostname is to be always replaced by the output
of `hostname -f`. Put it also in /etc/hosts as something like:
127.0.0.1 localhost myhostname
::1 localhost myhostname
New /etc/mail/freebsd.mc as follows, back up the old:
Code:
VERSIONID(`2021-03-11 sendmail as client on FreeBSD 11.4')
OSTYPE(freebsd6)
DOMAIN(generic)
dnl
FEATURE(`use_cw_file')dnl * requires /etc/mail/local-host-names
FEATURE(genericstable, `hash -o /etc/mail/genericstable')dnl
GENERICS_DOMAIN(`myhostname')dnl **1 myhostname = `hostname -f`
FEATURE(`masquerade_envelope')dnl
FEATURE(`local_no_masquerade')dnl
FEATURE(authinfo,`hash /etc/mail/auth/client')dnl
FEATURE(`no_default_msa')dnl
dnl
dnl CLIENT_OPTIONS(`Family=inet6, Address=::')dnl
CLIENT_OPTIONS(`Family=inet, Address=0.0.0.0')dnl
define(`CERT_DIR', `/etc/mail/certs')dnl * Certs must be created
define(`confCACERT_PATH', `CERT_DIR')dnl
define(`confCACERT', `CERT_DIR/cacert.pem')dnl
define(`confCLIENT_CERT', `CERT_DIR/host.cert')dnl
define(`confCLIENT_KEY', `CERT_DIR/host.key')dnl
define(`confDH_PARAMETERS',`CERT_DIR/dh.param')dnl
dnl
define(`SMART_HOST', `smtp:smtp.gmail.com')dnl **2 mail provider
define(`RELAY_MAILER_ARGS', `TCP $h 465')dnl **3 port like 587, 465
define(`ESMTP_MAILER_ARGS', `TCP $h 465')dnl **3
define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl
define(`confAUTH_OPTIONS', `A p y')dnl
dnl
MAILER(local)
MAILER(smtp)
**1: myhostname must be substituted with the output of `hostname -f`.
**2: "smtp.gmail.com" must be the smtp server
**3: here goes the port of the smtp server using tls / starttls.
This configuration needs that the following files be created:
(1) /etc/mail/local-host-names
It contains the domains considered local in separated lines, here:
localhost
myhostname
where myhostname is the output of `hostname -f`
(2) /etc/mail/genericstable
It contains a mapping from local email addresses to the ones passed
to the smtp server in "From header" and envelope, here the only line:
@myhostname mygooglename@gmail.com
where myhostname is the output of `hostname -f`
(3) Do first "
mkdir /etc/mail/auth
"./etc/mail/auth/client contains the name of the smtp server, your
username there and password there, here:
AuthInfo:smtp.gmail.com "U:mygooglename@gmail.com" "P:mygooglepass"
After creating the files do:
# cd /etc/mail
# makemap hash genericatable < genericstable
# chmod 700 /etc/mail/auth
# cd /etc/mail/auth
# makemap hash client < client
# chmod 600 client client.db
# cd ..
(after any change of genericstable or auth/client run the corresponding makemap that generates .db files)
After every configuration, do the following in /etc/mail to make it active:
# rm myhostname.mc myhostname.cf (myhostname is output of `hostname -f`)
# make cf
# make install
# make restart
Then test sending a mail with:
# mail emailaddress
or verbose:
# mail -v emailaddress
--
Sources:
(1) In /usr/share/sendmail/cf/README :
"SMTP AUTHENTICATION ->
Providing SMTP AUTH Data when sendmail acts as Client"
(2) http://www.sendmail.org/~ca/email/auth.html#authconf
(3) /usr/share/doc/smm/08.sendmailop/paper.ascii.gz
Page 66, AuthOptions
(4) https://docs.oracle.com/cd/E37670_01/E41138/html/ch15s06.html