PROXMOX 6: Configuración de postfix – gmail

PROXMOX 6: Configuración de postfix - gmail
  • Instalamos
apt-get install openssl ssl-cert postfix mailutils openssl ssl-cert mailutils libsasl2-2 ca-certificates libsasl2-modules -y
  • Modificamos el siguiente archivo:
nano /etc/postfix/main.cf
  • Lo editamos como sigue, primero eliminamos o comentamos la linea «relayhost =»
  • Luego agregamos lo siguiente al final del archivo
# SMTP relayhost
relayhost = [smtp.gmail.com]:587
## TLS Settings
smtp_tls_loglevel = 1
smtp_tls_CAfile = /etc/postfix/certs/CAcert.pem
smtp_tls_cert_file = /etc/postfix/certs/mycert.pem
smtp_tls_key_file = /etc/postfix/certs/mykey.pem
smtp_use_tls = yes
smtpd_tls_CAfile = /etc/postfix/certs/CAcert.pem
smtpd_tls_cert_file = /etc/postfix/certs/mycert.pem
smtpd_tls_key_file = /etc/postfix/certs/mykey.pem
smtpd_tls_received_header = yes
smtpd_use_tls = yes
# configuracao tls
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
# alias de mapeamento interno para externo
smtp_generic_maps = hash:/etc/postfix/generic
  • El archivo debe quedar como sigue
  • Creamos un archivo
nano /etc/postfix/sasl_passwd
  • Agregamos lo siguiente
[smtp.gmail.com]:587    interuniversitariadealajuela@gmail.com:AC2
  • Creamos otro archivo
nano /etc/postfix/generic
  • Agregamos lo siguiente
root@localhost.localdomain	interuniversitariadealajuela@gmail.com
  • Otorgar permisos y generar archivos .db
chmod 600 /etc/postfix/sasl_passwd 
chmod 600 /etc/postfix/generic
postmap /etc/postfix/sasl_passwd
postmap /etc/postfix/generic

#Debian 10
/usr/sbin/postmap /etc/postfix/sasl_passwd
/usr/sbin/postmap /etc/postfix/generic
  • Creamos los certificados en /etc/postfix/certs/
mkdir /etc/postfix/certs/
cd /etc/postfix/certs/
openssl dsaparam -out dsaparam.pem 2048
openssl req -x509 -nodes -days 3650 -newkey dsa:dsaparam.pem -out mycert.pem -keyout mykey.pem
  • RESULTADO:
CGenerating a 2048 bit DSA private key
writing new private key to 'mykey.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CR
State or Province Name (full name) [Some-State]:Alajuela
Locality Name (eg, city) []:Alajuela
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SIUA
Organizational Unit Name (eg, section) []:UGIT
Common Name (e.g. server FQDN or YOUR name) []:UGIT
Email Address []:interuniversitariadealajuela@gmail.com
  • Continuamos
ln -s mycert.pem CAcert.pem
openssl req -x509 -new -days 3650 -key /etc/postfix/certs/mykey.pem -out /etc/postfix/certs/mycert.pem
  • RESULTADO:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CR
State or Province Name (full name) [Some-State]:Alajuela
Locality Name (eg, city) []:Alajuela
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SIUA
Organizational Unit Name (eg, section) []:UGIT
Common Name (e.g. server FQDN or YOUR name) []:UGIT
Email Address []:interuniversitariadealajuela@gmail.com
  • Eliminamos el certificado:
rm dsaparam.pem
  • Reiniciamos el postfix
/etc/init.d/postfix reload
  • Comprobar el envió
echo "esta es la prueba de envio de correo" | mail -s "este es mi asunto" gustavo.matamoros@gmail.com