lwc:linux:postfix

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lwc:linux:postfix [2021/09/25 10:23] John Harrisonlwc:linux:postfix [2025/10/20 15:40] (current) John Harrison
Line 24: Line 24:
 sudo postfix stop; sudo postfix start; sudo postfix reload sudo postfix stop; sudo postfix start; sudo postfix reload
 </code> </code>
 +=== Alternative allowing multiple from addresses to map to multiple to addresses (better than above solution?) ===
 +from [[https://serverfault.com/questions/147921/forcing-the-from-address-when-postfix-relays-over-smtp]] (example shown):
 +<code>
 +/etc/postfix/main.cf:
 +    smtp_generic_maps = hash:/etc/postfix/generic
 +
 +/etc/postfix/generic:
 +    user@localdomain.local      account@isp.example.com
 +    @localdomain.local          wholedomain@isp.example.com
 +Then do:
 +
 +sudo postmap /etc/postfix/generic
 +sudo /etc/init.d/postfix reload
 +</code>
 +
 === Remap root@localhost to another to address === === Remap root@localhost to another to address ===
   * add ''root:        <EMAILADDR>'' to ''/etc/aliases''   * add ''root:        <EMAILADDR>'' to ''/etc/aliases''
   * ''sudo newaliases''   * ''sudo newaliases''
 === test === === test ===
 +Test with sendmail:
 <code> <code>
 sendmail -f sender@example.com recipient@example.com # -f allows you to specify from and is not required sendmail -f sender@example.com recipient@example.com # -f allows you to specify from and is not required
Line 35: Line 51:
 . .
 </code> </code>
 +or [[https://www.thomas-krenn.com/en/wiki/Test_TCP_Port_25_(smtp)_access_with_telnet|test with telnet]]
 +
 === Tips === === Tips ===
 +
   * postfix should be set up with no configuration. When you do this, there are instructions given at the end to copy some sort of sample configuration.   * postfix should be set up with no configuration. When you do this, there are instructions given at the end to copy some sort of sample configuration.
   * to reconfigure: ''sudo dpkg-reconfigure postfix''   * to reconfigure: ''sudo dpkg-reconfigure postfix''
   * to reload the settings: ''sudo postfix stop; sudo postfix start; sudo postfix reload''   * to reload the settings: ''sudo postfix stop; sudo postfix start; sudo postfix reload''
   * when testing ''tail -f /var/log/mail.log'' is your friend   * when testing ''tail -f /var/log/mail.log'' is your friend
 +  * view queued mail: ''postqueue -p''
 +  * flush queued mail: ''postqueue -f''
 +  * purge all queued mail: ''sudo postsuper -d ALL''
 +  * testing smtp connection and credentials from cli
 +    * port 465: ''swaks --to recipient@example.com --from sender@yourdomain.com --server smtp-server --port 465 --tls-on-connect --auth-user 'your_username' --auth-password 'your_password' ''
 +    * port 587: ''swaks --to recipient@example.com --from sender@yourdomain.com --server smtp-server --auth-user 'your_username' --auth-password 'your_password' -p 587 --tls''
 +    * //port 465 is legacy and 587 is the better choice for modern systems//
 +
 +
 +
 +
 +
 +
 +
 ==== Optional ==== ==== Optional ====
   * get current hostname: ''hostname''   * get current hostname: ''hostname''
   * set hostname with ''hostnamectl set-hostname <HOSTNAME>''   * set hostname with ''hostnamectl set-hostname <HOSTNAME>''
  
  • lwc/linux/postfix.1632583384.txt.gz
  • Last modified: 2021/09/25 10:23
  • by John Harrison