Installing sympa on FreeBSD


The name of this piece of software is a lie

August 2017.
The FreeBSD logo Image

Let's install sympa with postfix on a FreeBSD jail.

Install sympa


Install the port:

# make -C /usr/ports/mail/sympa install clean

Make sure the syslog entries of sympa are stored into a separate log file:

# mkdir -p /usr/local/etc/syslog.d
# echo "local1.* /var/log/sympa" > /usr/local/etc/syslog.d/sympa
# service syslogd reload

Make sure sympa is allowed to write into its data and bounce directory:

# chown root:sympa /usr/local/share/sympa/list_data
# chmod 770 /usr/local/share/sympa/list_data
# chown root:sympa /usr/local/share/sympa/bounce
# chmod 770 /usr/local/share/sympa/bounce

Make sure sympa is allowed to write into its config directory:

# chown root:sympa /usr/local/etc/sympa
# chmod 770 /usr/local/etc/sympa
# chown root:sympa /usr/local/etc/sympa/sympa.conf

In my opinion, this is plain stupid. Running software should not be able to edit its config files.

Make sure sympa is allowed to write into its shared directory:

# chown root:sympa /usr/local/share/sympa
# chmod 705 /usr/local/share/sympa

Also, I think this is bad practice.

Make sure sympa is allowed to write into the system mail config directory:

# chown root:sympa /etc/mail
# chmod 770 /etc/mail

Do I like this? Absolutely not.
In particular, sympa needs to write into /etc/mail/aliases.db. If that file already exists on your system, give it a good chown as well.

Edit /usr/local/etc/sympa/sympa.conf to your need. Here's a basic configuration:

domain sympa.example.com
listmaster admin@example.com
wwsympa_url http://sympa.example.com/wws
cookie add69524c8a75f47c05ccb47f96c9195
db_type mysql
db_host 192.168.0.2
db_name sympa
db_user sympa
db_passwd Ujzz6YVdEXppajM
static_content_path /usr/local/share/sympa
static_content_url /static-sympa
sendmail_aliases /usr/local/share/sympa/list_data/sympa_aliases

Configuring the database of sympa is out of the scope of this article. Here I'm simply using MySQL.

Enable the service:

# sysrc sympa_enable="YES"

Start the service:

# service sympa start

Installing and configuring postfix


Install postfix:

# Make -C /usr/ports/mail/postfix install clean

Edit the main config (/usr/local/etc/postfix/main.cf) and configure a transport and a map file for sympa:

myhostname = sympa.example.com
mydomain = sympa.example.com
mydestination = localhost, sympa.example.com
recipient_delimiter = +
mailbox_size_limit = 0
transport_maps = regexp:/usr/local/etc/postfix/transport_regexp_sympa
sympa_destination_recipient_limit = 1
sympabounce_destination_recipient_limit = 1
alias_maps = hash:/etc/mail/aliases,hash:/usr/local/share/sympa/list_data/sympa_aliases
alias_database = hash:/etc/mail/aliases,hash:/usr/local/share/sympa/list_data/sympa_aliases

/usr/local/etc/postfix/transport_regexp_sympa:

/^.*\-owner@sympa\.example\.com$/ sympabounce:
/^.*\@sympa\.example\.com$/ sympa:

Edit the transport file (/usr/local/etc/postfix/master.cf) and add transports to sympa:

sympa unix - n n - - pipe
flags=R user=sympa argv=/usr/local/libexec/sympa/queue ${recipient}
sympabounce unix - n n - - pipe
flags=R user=sympa argv=/usr/local/libexec/sympa/bouncequeue ${recipient}

Enable and start postfix:

# sysrc postfix_enable="YES"
# service postfix start

Installing the web interface (wwsympa)



Install dependencies:

# make -C /usr/ports/databases/p5-DBD-mysql install clean
# make -C /usr/ports/www/p5-CGI-Fast install clean

Install nginx and fcgiwrap:

# make -C /usr/ports/www/nginx install clean
# make -C /usr/ports/www/fcgiwrap install clean

Configure a profile in /etc/rc.conf and enable the service:

fcgiwrap_enable="YES"
fcgiwrap_profiles="sympa"
fcgiwrap_sympa_socket="unix:/tmp/fcgiwrap_sympa.sock"
fcgiwrap_sympa_user="sympa"
fcgiwrap_sympa_socket_owner="sympa"
fcgiwrap_sympa_socket_group="www"
fcgiwrap_sympa_socket_mode="0770"

Start the service and check that it's listening correctly:

# service fcgiwrap start
# sockstat -l | grep fcgiwrap
sympa fcgiwrap 79058 0 stream /tmp/fcgiwrap_sympa.sock

Add a server to the configuration files of nginx:

server {
listen 80;
server_name sympa.example.com;
access_log /var/log/nginx/sympa-access.log;
error_log /var/log/nginx/sympa-error.log;
index wws/;
location /static-sympa {
alias /usr/local/share/sympa;
access_log off;
}

location / {
gzip off;
fastcgi_pass unix:/tmp/fcgiwrap_sympa.sock;
fastcgi_split_path_info ^(/wws)(.+)$;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param SCRIPT_FILENAME /usr/local/libexec/sympa/wwsympa-wrapper.fcgi;
fastcgi_param HTTP_HOST sympa.example.com;
fastcgi_intercept_errors on;
}
}

Enable and start nginx:

# sysrc nginx_enable="YES"
# service nginx start

The web interface is now available.
WWSympa running on FreeBSD

If everything went well, you can now create a list:

WWSympa showing a newly created list

You can check that the alias file was updated correctly:

# cat /usr/local/share/sympa/list_data/sympa_aliases
## This aliases file is dedicated to Sympa Mailing List Manager
## You should edit your sendmail.mc or sendmail.cf file to declare it
#------------------------------ test_list: list alias created 22 Aug 2017
test_list: "| /usr/local/libexec/sympa/queue test_list@sympa.example.com"
test_list-request: "| /usr/local/libexec/sympa/queue test_list-request@sympa.example.com"
test_list-editor: "| /usr/local/libexec/sympa/queue test_list-editor@sympa.example.com"
#test_list-subscribe: "| /usr/local/libexec/sympa/queue test_list-subscribe@sympa.example.com"
test_list-unsubscribe: "| /usr/local/libexec/sympa/queue test_list-unsubscribe@sympa.example.com"
test_list-owner: "| /usr/local/libexec/sympa/bouncequeue test_list@sympa.example.com"

Test everything


Send a test email:

echo "Est-elle brune, blonde ou rousse ? - Je l'ignore." | mail -s "Test email" test_list@sympa.example.com

Check /var/log/maillog:

Dec 7 21:49:16 sympa1 postfix/qmgr[47576]: 987058465: from=<user1@example.com>, size=1378, nrcpt=1 (queue active)
Dec 7 21:49:17 sympa1 postfix/pipe[76920]: 987058465: to=<test_list@sympa.example.com>, relay=sympa, delay=1.1, delays=0.02/0/0/1.1, dsn=2.0.0, status=sent (delivered via sympa service)
Dec 7 21:49:17 sympa1 postfix/qmgr[47576]: 987058465: removed
Dec 7 21:49:17 sympa1 postfix/smtpd[76916]: connect from unknown[10.9.0.101]
Dec 7 21:49:18 sympa1 postfix/qmgr[47576]: 1119E8478: from=<test_list-owner@sympa.example.com>, size=2274, nrcpt=1 (queue active)
Dec 7 21:49:18 sympa1 postfix/smtp[76926]: 1119E8478: to=<user2@example.com>, relay=mail1.example.net[198.51.100.35]:25, delay=0.77, delays=0.32/0.01/0.08/0.36, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 7E4E45EA7)
Dec 7 21:49:18 sympa1 postfix/qmgr[47576]: 1119E8478: removed

Check /var/log/messages:

Dec 07 21:49:16 sympa1 sympa_msg[47458]: notice Sympa::Spindle::ProcessIncoming::_twist() Processing Sympa::Message <test_list@sympa.example.com.1512683356.76921>; envelope_sender=user1@example.com; message_id=eme4db733a-c660-45fd-bdf5-37968cdbdc1e@rasa; sender=user1@example.com
Dec 07 21:49:16 sympa1 sympa_msg[47458]: notice Sympa::Spool::store() Sympa::Message <test_list@sympa.example.com.1512683356.76921> is stored into Sympa::Spool::Archive as <1512683356.1512683356.964608.test_list@sympa.example.com,47458,8945>
Dec 07 21:49:16 sympa1 sympa_msg[47458]: notice Sympa::Spool::store() Sympa::Message <test_list@sympa.example.com.1512683356.76921> is stored into Sympa::Spool::Digest <test_list@sympa.example.com> as <1512683356.1512683356.978756,47458,7735>
Dec 07 21:49:16 sympa1 sympa_msg[47458]: notice Sympa::Bulk::store() Message Sympa::Message <test_list@sympa.example.com.1512683356.76921> is stored into bulk spool as <5.5.1512683356.1512683356.985672.test_list@sympa.example.com_z,47458,6615>
Dec 07 21:49:16 sympa1 sympa_msg[47458]: notice Sympa::Spindle::ToList::_send_msg() No VERP subscribers left to distribute message to list Sympa::List <test_list@sympa.example.com>
Dec 07 21:49:18 sympa1 bulk[47461]: notice Sympa::Mailer::store() Done sending message Sympa::Message <5.5.1512683356.1512683356.985672.test_list@sympa.example.com_z,47458,6615/z> for Sympa::List <test_list@sympa.example.com> (priority 5) in 2 seconds since scheduled expedition date