El proceso de enviar un correo electrónico de una persona a otra a través de una red o de Internet involucra muchos sistemas trabajando juntos. Todos esos sistemas deben estar configurados correctamente para que el proceso funcione. El remitente usa un Agente de Usuario de Correo (Mail User Agent, MUA), o cliente de correo, para enviar el mensaje a través de uno o varios Agentes de Transferencia de Correo (Mail Transport Agent, MTA), el último de los cuales actuará de Agente de Entrega de Correo (Mail Delivery Agent, MDA) para entregarlo en el buzón del destinatario, y que luego pueda ser recuperado usando el cliente de correo del destinatario, normalmente por medio de un servidor POP3 o IMAP.
Postfix es el Agente de Transferencia de Correo (Mail Transfer Agent, MTA) predeterminado en Ubuntu. Su objetivo es ser rápido, seguro y fácil de administrar. Es compatible con el MTA sendmail. Esta sección explica cómo instalar y configurar postfix. También explica cómo configurar un servidor SMTP usando una conexión segura (para enviar correos electrónicos de forma segura).
Para instalar postfix con SMTP-AUTH y Transport Layer Security (TLS), ejecute la siguiente orden:
sudo apt-get install postfix
Cuando el proceso de instalación le haga preguntas, simplemente pulse Intro; la configuración se hará con más detalle en la siguiente etapa.
Para configurar postfix, ejecute la siguiente orden:
sudo dpkg-reconfigure postfix
Se mostrará la interfaz de usuario. En cada pantalla, seleccione los siguientes valores:
Ok
Sitio de Internet
NONE
mail.example.com
mail.example.com, localhost.localdomain, localhost
No
127.0.0.0/8
Sí
0
+
todo
Reemplace mail.example.com con el nombre de máquina de su servidor de correo.
El siguiente paso es configurar postfix para que use SASL con SMTP AUTH. En lugar de editar directamente el archivo de configuración, puede usar la orden postconf para configurar todos los parámetros de postfix. Los parámetros de configuración se almacenarán en el archivo /etc/postfix/main.cf
. Posteriormente, si desea reconfigurar un parámetro en particular, podrá ejecutar la misma orden o cambiar el parámetro manualmente en el archivo.
Configurar Postfix para hacer SMTP AUTH usando SASL (saslauthd):
↵ postconf -e 'smtpd_sasl_local_domain ='↵ postconf -e 'smtpd_sasl_auth_enable = yes'↵ postconf -e 'smtpd_sasl_security_options = noanonymous'↵ postconf -e 'broken_sasl_auth_clients = yes'↵ postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'↵ postconf -e 'inet_interfaces = all'↵ echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf↵ echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.conf↵
A continuación, configure el certificado digital para TLS. Cuando se le pregunte, siga las instrucciones y responda adecuadamente.
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024 chmod 600 smtpd.key openssl req -new -key smtpd.key -out smtpd.csr openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt openssl rsa -in smtpd.key -out smtpd.key.unencrypted mv -f smtpd.key.unencrypted smtpd.key openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650 mv smtpd.key /etc/ssl/private/ mv smtpd.crt /etc/ssl/certs/ mv cakey.pem /etc/ssl/private/ mv cacert.pem /etc/ssl/certs/
Puede conseguir el certificado digital solicitándosela a una autoridad de certificación. También puede crear el certificado usted mismo. Vea “Creación de un certificado auto-firmado” para más detalles.
Configurar Postfix para hacer cifrado TLS con el correo entrante y saliente:
postconf -e 'smtpd_tls_auth_only = no' postconf -e 'smtp_use_tls = yes' postconf -e 'smtpd_use_tls = yes' postconf -e 'smtp_tls_note_starttls_offer = yes' postconf -e 'smtpd_tls_key_file = /etc/ssl/private/smtpd.key' postconf -e 'smtpd_tls_cert_file = /etc/ssl/certs/smtpd.crt' postconf -e 'smtpd_tls_CAfile = /etc/ssl/certs/cacert.pem' postconf -e 'smtpd_tls_loglevel = 1' postconf -e 'smtpd_tls_received_header = yes' postconf -e 'smtpd_tls_session_cache_timeout = 3600s' postconf -e 'tls_random_source = dev:/dev/urandom' postconf -e 'myhostname = mail.ejemplo.com'
Una vez que haya ejecutado todas las órdenes, tendrá configurado el SMTP AUTH en postfix. El certificado auto-firmado se crea para el TLS y se configura con postfix.
Ahora,·el archivo·/etc/postfix/main.cf
·debería parecerse a
La configuración inicial de postfix se ha completado. Ejecute la siguiente orden para arrancar el demonio de postfix:
sudo /etc/init.d/postfix start
Ahora, el demonio postfix está instalado y configurado, y se está ejecutando con éxito. Postfix soporta SMTP AUTH como se define en RFC2554. Está basado en SASL. Sin embargo, todavía es necesario configurar la autenticación SASL para poder usar SMTP.
Los paquetes libsasl2, sasl2-bin y libsasl2-modules son necesarios para habilitar el SMTP AUTH usando SASL. Puede instalar estas aplicaciones si no las tenía ya instaladas.
apt-get install libsasl2 sasl2-bin
Se necesitan unos pocos cambios para hacer que funcione apropiadamente. Como Postfix se ejecuta «enjaulado» con chroot en /var/spool/postfix
, es necesario configurar SASL para ejecutarlo en un raíz falso (/var/run/saslauthd
se convierte en /var/spool/postfix/var/run/saslauthd
):
mkdir -p /var/spool/postfix/var/run/saslauthd rm -rf /var/run/saslauthd
Para activar saslauthd, edite el archivo /etc/default/saslauthd
y cambie o añada la variable START. Con idea de configurar saslauthd para que se pueda ejecutar en un falso raíz, añada las variables PWDIR, PIDFILE y PARAMS. Finalmente, configure la variable MECHANISMS a su gusto. El archivo debe tener el siguiente aspecto:
↵ # This needs to be uncommented before saslauthd will be run↵ # automatically↵ START=yes↵ ↵ PWDIR="/var/spool/postfix/var/run/saslauthd"↵ PARAMS="-m ${PWDIR}"↵ PIDFILE="${PWDIR}/saslauthd.pid"↵ ↵ # You must specify the authentication mechanisms you wish to use.↵ # This defaults to "pam" for PAM support, but may also include↵ # "shadow" or "sasldb", like this:↵ # MECHANISMS="pam shadow"↵ ↵ MECHANISMS="pam"↵
Si lo prefiere, puede usar shadow en lugar de pam. De esta forma, se transferirán contraseñas cifradas con MD5, lo que resultará más seguro. El nombre de usuario y la contraseña que haya que autenticar serán los de los usuarios del sistema que esté usando en el servidor.
A continuación, actualice el «estado» de dpkg de /var/spool/portfix/var/run/saslauthd
. El script de inicialización de saslauthd usa esta opción para crear el directorio que falta con los permisos y propietario adecuados:
dpkg-statoverride --force --update --add root sasl 755 /var/spool/postfix/var/run/saslauthd
La configuración del SMTP AUTH está ya completa. Ahora es el momento de iniciar y probar la configuración. Puede ejecutar la siguiente orden para arrancar el demonio SASL:
sudo /etc/init.d/saslauthd start
Para ver si el SMTP-AUTH y el TLS funcionan correctamente, ejecute la siguiente orden:
telnet mail.example.com 25
Una vez que haya establecido la conexión con el servidor de correo postfix, teclee:
ehlo mail.ejemplo.com
Si ve aparecer las siguientes líneas (entre otras), es que todo funciona correctamente. Teclee quit para salir.
↵ 250-STARTTLS↵ 250-AUTH LOGIN PLAIN↵ 250-AUTH=LOGIN PLAIN↵ 250 8BITMIME↵
Exim4 is is another Message Transfer Agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the internet. Exim can be installed in place of sendmail, although the configuration of exim is quite different to that of sendmail.
Para instalar exim4, ejecute el siguiente comando:
↵
sudo apt-get install exim4 exim4-base exim4-config↵
To configure exim4, run the following command:
sudo dpkg-reconfigure exim4-config
The user interface will be displayed. The user interface lets you configure many parameters. For example, In exim4 the configuration files are split among multiple files. If you wish to have them in one file you can configure accordingly in this user interface.
All the parameters you configure in the user interface are
stored in
/etc/exim4/update-exim4.conf.conf
file.
If you wish to re-configure, either you re-run the
configuration wizard or manually edit this file
using your favourite editor. Once you configure, you can run
the following command to generate the master configuration
file:
sudo update-exim4.conf
The master configuration file, is generated and
it is stored in
/var/lib/exim4/config.autogenerated
.
At any time, you should not edit the master configuration
file,
/var/lib/exim4/config.autogenerated
manually. It is updated automatically every time you run
update-exim4.conf
You can run the following command to start exim4 daemon.
sudo /etc/init.d/exim4 start
TODO: This section should cover configuring SMTP AUTH with exim4.
Dovecot is a Mail Delivery Agent, written with security primarily in mind. It supports the major mailbox formats: mbox or Maildir. This section explain how to set it up as an imap or pop3 server.
To install dovecot, run the following command in the command prompt:
sudo apt-get install dovecot-common dovecot-imapd dovecot-pop3d
To configure dovecot, you can edit the file
/etc/dovecot/dovecot.conf
. You can
choose the protocol you use. It could be pop3, pop3s (pop3
secure), imap and imaps (imap secure). A description of these protocols is beyond the scope of this guide. For further information, refer to the wikipedia articles on POP3 and
IMAP.
IMAPS and POP3S are more secure that the simple IMAP and
POP3 because they use SSL encryption to connect. Once you
have chosen the protocol, amend the following line in the file
/etc/dovecot/dovecot.conf
:
↵ protocols = pop3 pop3s imap imaps↵
It enables the protocols when dovecot is started. Next, add the following line in pop3 section in the file /etc/dovecot/dovecot.conf
:
↵ pop3_uidl_format = %08Xu%08Xv↵
Next, choose the mailbox you use. Dovecot supports maildir and mbox formats. These are the most commonly used mailbox formats. They both have their own benefits and they are discussed on the dovecot website.
Once you have chosen your mailbox type, edit the file
/etc/dovecot/dovecot.conf
and change
the following line:
↵ default_mail_env = maildir:~/Maildir # (for maildir)↵ or↵ default_mail_env = mbox:~/mail:INBOX=/var/spool/mail/%u # (for mbox)↵
You should configure your Mail Trasport Agent (MTA) to transfer the incoming mail to this type of mailbox if it is different from the one you have configured.
Once you have configured dovecot, start the dovecot daemon in order to test your setup:
sudo /etc/init.d/dovecot start
If you have enabled imap, or pop3, you can also try to log in with the commands telnet localhost pop3 or telnet localhost imap2. If you see something like the following, the installation has been successful:
↵ bhuvan@rainbow:~$ telnet localhost pop3↵ Trying 127.0.0.1...↵ Connected to localhost.localdomain.↵ Escape character is '^]'.↵ +OK Dovecot ready.↵
To configure dovecot to use SSL, you can edit the file
/etc/dovecot/dovecot.conf
and amend
following lines:
↵ ssl_cert_file = /etc/ssl/certs/dovecot.pem↵ ssl_key_file = /etc/ssl/private/dovecot.pem↵ ssl_disable = no↵ disable_plaintext_auth = no↵
The cert and key files are created automatically by dovecot when you install it. Please note that these keys are not signed and will give "bad signature" errors when connecting from a client. To avoid this, you can use commercial certificates, or even better, you can use your own SSL certificates.
Mailman is an open source program for managing electronic mail discussions and e-newsletter lists. Many open source mailing lists (including all the Ubuntu mailing lists) use Mailman as their mailing list software. It is powerful and easy to install and maintain.
Mailman suministra un interface web para administradores y usuarios. Por lo tanto, requiere apache con soporte mod_perl. Mailman usa un servidor de correo externo para enviar y recibir emails. Funciona perfectamente con los siguientes servidores de correo:
Postfix
Exim
Sendmail
Qmail
Veremos como instalar mailman, el servidor web apache y el servidor de correo Exim. Si desea instalar mailman con un servidor de correo diferente, remitase a las secciones que lo referencian.
Para instalar apache2 remitase a “Instalación”.
Para instalar Exim4 ejecute los siguiente comandos en un terminal:
↵ sudo apt-get install exim4↵ sudo apt-get install exim4-base↵ sudo apt-get install exim4-config↵
Una vez que exim4 este instalado, los archivos de configuración son guardados en el directorio /etc/exim4
. En ubuntu, por defecto, los archivos de configuración de exim4 son divididos en distintos archivos. Puede cambiar este comportamiento cambiando la siguiente variable en el archivo /etc/exim4/update-exim4.conf
:
dc_use_split_config='true'
Para instalar Mailman, ejecute esta orden en una terminal:
sudo apt-get install mailman
Eso copia los archivos de instalación en el directorio /var/lib/mailman, instala los scripts CGI en el directorio /usr/lib/cgi-bin/mailman, crea una lista de usuarios de linux y la lista de grupos de linux. El proceso mailman será propiedad de este usuario.
Esta sección asume que instaló con éxito mailman, apache2, y exim4. Ahora solo necesita configurarlos.
Once apache2 is installed, you can add the following lines in
the /etc/apache2/apache2.conf
file:
↵ Alias /images/mailman/ "/usr/share/images/mailman/"↵ Alias /pipermail/ "/var/lib/mailman/archives/public/"↵
Mailman uses apache2 to render its CGI scripts. The mailman CGI scripts
are installed in the /usr/lib/cgi-bin/mailman
directory. So, the mailman url will be
http://hostname/cgi-bin/mailman/. You can make changes to the
/etc/apache2/apache2.conf
file if you wish to
change this behavior.
Una vez que Exim4 este instalado, puede ejecutar el servidor Exim usando el siguiente comando en un terminal:
↵
sudo apt-get /etc/init.d/exim4 start↵
Para hacer que mailman mailman funcione con exim4, necesita configurar exim4. Como se menciono antes, por defecto, exim4 usa multiples archivos de configuración de diferentes tipos. Para más detalles, remitase al sitio web de Exim. Para ejecutar mailman, deberiamos de añadir un archivo de configuración con el siguiente tipo de configuración:
Principal
Transporte
Enrutamiento
Exim crea un archivo principal de configuración ordenando todos los miniarchivos de configuración. Por lo tanto, el orden de estos archivos de configuración es muy importante.
Todos los archivos de configuración pertenecientes al tipo principal son guardados en el directorio /etc/exim4/conf.d/main/
. Puede añadir el contenido siguiente a un archivo nuevo, llamado 04_exim4-config_mailman
:
↵ # start↵ # Home dir for your Mailman installation -- aka Mailman's prefix↵ # directory.↵ # On Ubuntu this should be "/var/lib/mailman"↵ # This is normally the same as ~mailman↵ MM_HOME=/var/lib/mailman↵ #↵ # User and group for Mailman, should match your --with-mail-gid↵ # switch to Mailman's configure script. Value is normally "mailman"↵ MM_UID=list↵ MM_GID=list↵ #↵ # Domains that your lists are in - colon separated list↵ # you may wish to add these into local_domains as well↵ domainlist mm_domains=hostname.com↵ #↵ # -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=↵ #↵ # These values are derived from the ones above and should not need↵ # editing unless you have munged your mailman installation↵ #↵ # The path of the Mailman mail wrapper script↵ MM_WRAP=MM_HOME/mail/mailman↵ #↵ # The path of the list config file (used as a required file when↵ # verifying list addresses)↵ MM_LISTCHK=MM_HOME/lists/${lc::$local_part}/config.pck↵ # end↵
All the configuration files belonging to transport type are stored in
the /etc/exim4/conf.d/transport/
directory. You
can add the following content to a new file named
40_exim4-config_mailman
:
↵ mailman_transport:↵ driver = pipe↵ command = MM_WRAP \↵ '${if def:local_part_suffix \↵ {${sg{$local_part_suffix}{-(\\w+)(\\+.*)?}{\$1}}} \↵ {post}}' \↵ $local_part↵ current_directory = MM_HOME↵ home_directory = MM_HOME↵ user = MM_UID↵ group = MM_GID↵
All the configuration files belonging to router type are stored in the
/etc/exim4/conf.d/router/
directory. You can add the following content
in to a new file named 101_exim4-config_mailman
:
↵ mailman_router:↵ driver = accept↵ require_files = MM_HOME/lists/$local_part/config.pck↵ local_part_suffix_optional↵ local_part_suffix = -bounces : -bounces+* : \↵ -confirm+* : -join : -leave : \↵ -owner : -request : -admin↵ transport = mailman_transport↵
The order of main and transport configuration files can be in any order. But, the order of router configuration files must be the same. This particular file must appear before the 200_exim4-config_primary file. These two configuration files contain same type of information. The first file takes the precedence. For more details, please refer to the references section.
Una vez que mailman esta instalado, puede ejecutarlo usantdo el comando:
↵
sudo /etc/init.d/mailman start↵
Una vez que mailman esta instalado, puede crear la lista de correo por defecto. Ejecute el siguiente comando para crear esta lista:
↵
sudo /usr/sbin/newlist mailman↵
↵
Enter the email address of the person running the list: bhuvan at ubuntu.com↵
Initial mailman password:↵
To finish creating your mailing list, you must edit your /etc/aliases
(or↵
equivalent) file by adding the following lines, and possibly running the↵
`newaliases' program:↵
↵
## mailman mailing list↵
mailman: "|/var/lib/mailman/mail/mailman post mailman"↵
mailman-admin: "|/var/lib/mailman/mail/mailman admin mailman"↵
mailman-bounces: "|/var/lib/mailman/mail/mailman bounces mailman"↵
mailman-confirm: "|/var/lib/mailman/mail/mailman confirm mailman"↵
mailman-join: "|/var/lib/mailman/mail/mailman join mailman"↵
mailman-leave: "|/var/lib/mailman/mail/mailman leave mailman"↵
mailman-owner: "|/var/lib/mailman/mail/mailman owner mailman"↵
mailman-request: "|/var/lib/mailman/mail/mailman request mailman"↵
mailman-subscribe: "|/var/lib/mailman/mail/mailman subscribe mailman"↵
mailman-unsubscribe: "|/var/lib/mailman/mail/mailman unsubscribe mailman"↵
↵
Hit enter to notify mailman owner...↵
↵
# ↵
Hemos configurado exim para que reconozca todos los emails del mailman. Por lo tanto, no es obligatorio que introduzca nuevas entradas en /etc/aliases
. Si usted hace algún cambio en los archivos de configuración, asegurese que reinicia esos servicios antes de continuar con la siguiente sección.
Asumimos que tiene una instalación por defecto. El cgi script del mailman todavía esta en el directorio /usr/lib/cgi-bin/mailman/. Mailman tiene la facilidad de poder administrase por web. Para acceder a esta página, introduzca la siguiente url en su navegador:
http://nombrehost/cgi-bin/mailman/admin
La lista de correo por defecto, mailman, aparecerá en su pantalla. Si hace click en el nombre de la lista, se le preguntará la password de autentificación. Si introduce la password correcta, será capaz de cambiar las configuraciones administrativas de la lista de correo. Puede crear una nueva lista usando una utilidad de la línea de comandos (/usr/sbin/newlist). Adicionalmente, puede crear nuevas listas de correo usando el interface web.
Mailman posee un interface de usuario web. Para acceder a esta página, introduzca la siguiente url en su navegador:
http://nombrehost/cgi-bin/mailman/listinfo
La lista de correo por defecto, mailman, aparecerá en esta pantalla. Si hace click sobre el nombre, se le mostrará un formulario de suscripción. Puede introducir su dirección de correo, nombre (opcional), y password para suscribirse. Le será enviado un email de invitación. Puede seguir las instrucciones de este email para suscribirse.