Postfix: Difference between revisions

From Leo's Notes
This page was last edited on 9 December 2021, at 20:55.
m Added categories
No edit summary
Line 1: Line 1:


== Mail Relay ==
==Mail Relay==
To use Postfix as a mail relay server, edit the {{code|/etc/postfix/main.cf}} configuration with the following:
To use Postfix as a mail relay server, edit the {{code|/etc/postfix/main.cf}} configuration file and set the <code>relayhost</code> value.


{{highlight|lang=terminal|code=
{{highlight|lang=text|code=
relayhost = [smtp.example.com]:587
relayhost = [smtp.example.com]:587
smtp_use_tls = yes
}}
 
Note that the server name is in square brackets, followed by the port number. For servers that require TLS, set the following as well:
 
{{Highlight
| code = smtp_use_tls = yes
smtp_sasl_auth_enable = no
smtp_sasl_auth_enable = no
| lang = text
}}
}}


This assumes that smtp.example.com accepts TLS encrypted SMTP connections via 587.
This assumes that smtp.example.com accepts TLS encrypted SMTP connections via 587.


== See Also ==
Restart postfix to apply these changes.
* https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/
 
=== Sending email messages ===
To send a HTML message:
{{Highlight
| code = $ (
    echo "To: user@example.com"
    echo "Subject: HTML test"
    echo "Content-Type: text/html"
    echo
    cat email-message.html
) {{!}} sendmail.postfix -t
| lang = terminal
}}
 
==See Also==
 
*https://www.howtoforge.com/tutorial/configure-postfix-to-use-gmail-as-a-mail-relay/


{{Navbox Linux}}[[Category:Linux]]
{{Navbox Linux}}
[[Category:Linux]]
[[Category:LinuxUtilities]]
[[Category:LinuxUtilities]]
[[Category:Networking]]
[[Category:Networking]]

Revision as of 20:55, 9 December 2021

Mail Relay

To use Postfix as a mail relay server, edit the /etc/postfix/main.cf configuration file and set the relayhost value.

relayhost = [smtp.example.com]:587

Note that the server name is in square brackets, followed by the port number. For servers that require TLS, set the following as well:

smtp_use_tls = yes
smtp_sasl_auth_enable = no

This assumes that smtp.example.com accepts TLS encrypted SMTP connections via 587.

Restart postfix to apply these changes.

Sending email messages

To send a HTML message:

$ (
    echo "To: user@example.com"
    echo "Subject: HTML test"
    echo "Content-Type: text/html"
    echo
    cat email-message.html
) | sendmail.postfix -t

See Also