DevOpsToolBox
OPEN_SOURCE
Postfix

Setting Up Postfix for SMTP

Install and Configure Postfix

  1. Install Postfix

    sudo apt update
    sudo apt install postfix -y
  2. Configure Postfix

    Edit the Postfix main configuration file:

    sudo nano /etc/postfix/main.cf

    Add or modify the following configurations:

    relayhost = [smtp.example.in]:1025  # Specify your SMTP relay host and port
    # Add user and password variables if needed
  3. Restart Postfix to Apply Changes

    sudo systemctl restart postfix
  4. Test Email Functionality

    Send a test email to verify the configuration:

    echo "Test email body" | mail -s "Test email subject" [email protected]

External SMTP Configuration (e.g., Gmail)

  1. Set Up Authentication for External SMTP

    Edit the sasl_passwd file to store your SMTP credentials:

    sudo nano /etc/postfix/sasl_passwd

    Add your SMTP credentials:

    [smtp.gmail.com]:587 [email protected]:xyz

    Important: Replace [email protected] and xyz with your actual Gmail username and app password.

  2. Secure the sasl_passwd File

    Set the appropriate permissions and create a hashed database:

    sudo chmod 600 /etc/postfix/sasl_passwd
    sudo postmap /etc/postfix/sasl_passwd
  3. Configure Postfix for External SMTP

    Edit the Postfix configuration file:

    sudo nano /etc/postfix/main.cf

    Add or modify the following configurations:

    smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
    myhostname = jira-server
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    mydestination = $myhostname, jira-dc10-server, jira-server, localhost.localdomain, localhost
    relayhost = [smtp.gmail.com]:587
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    inet_protocols = all
    
    smtp_sasl_auth_enable = yes
    smtp_sasl_security_options = noanonymous
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_use_tls = yes
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
  4. Restart Postfix to Apply Changes

    sudo systemctl restart postfix

Additional Resources


This guide should help you configure Postfix for both local and external SMTP servers. Make sure to replace placeholder values with your actual server details and credentials.


🧙 AI Wizard - Instant Page Insights

Click the button below to analyze this page.
Get an AI-generated summary and key insights in seconds.
Powered by Perplexity AI!