Guest User

Untitled

a guest
Jul 1st, 2021
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. [/etc/hosts]
  2. 127.0.0.1 localhost.localdomain localhost
  3. ::1 localhost6.localdomain6 localhost6
  4. <serverip> <machinename>.<mydomain>.<tld>
  5. <serverip> <mydomain>.<tld>
  6.  
  7. # The following lines are desirable for IPv6 capable hosts
  8. ::1 ip6-localhost ip6-loopback
  9. fe00::0 ip6-localnet
  10. ff00::0 ip6-mcastprefix
  11. ff02::1 ip6-allnodes
  12. ff02::2 ip6-allrouters
  13. ff02::3 ip6-allhosts
  14.  
  15. ---
  16. Using postfix -
  17.  
  18. [/etc/postfix/main.cf]
  19. ...
  20. myhostname = <machinename>.<mydomain>.<tld>
  21. mydomain = <mydomain>.<tld>
  22. myorigin = $mydomain
  23. ...
  24. relay_domains = hash:/etc/postfix/relay_domains
  25. ...
  26. readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
  27. smtpd_sasl_local_domain = $myhostname
  28. smtpd_sasl_auth_enable = yes
  29. smtpd_sasl_security_options = noanonymous
  30. broken_sasl_auth_clients = yes
  31. smtpd_sasl_authenticated_header = yes
  32. smtpd_recipient_restrictions =
  33. check_sender_access hash:/etc/postfix/sender_access,
  34. permit_sasl_authenticated,
  35. permit_mynetworks,
  36. reject_unauth_destination,
  37. regexp:/etc/postfix/banned-regexp
  38. #,check_relay_domains
  39. mynetworks = 127.0.0.0/8
  40. inet_protocols=ipv4
  41. smtpd_tls_auth_only = no
  42. smtp_use_tls = yes
  43. smtpd_use_tls = yes
  44. smtp_tls_note_starttls_offer = yes
  45. smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
  46. smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
  47. smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
  48. smtpd_tls_loglevel = 1
  49. smtpd_tls_received_header = yes
  50. smtpd_tls_session_cache_timeout = 3600s
  51. tls_random_source = dev:/dev/urandom
  52. home_mailbox = Maildir/
  53. unverified_sender_reject_code = 550
  54. #parent_domain_matches_subdomains = debug_peer_list,fast_flush_domains,mynetworks,permit_mx_backup_networks,qmqpd_authorized_clients,relay_domains,smtpd_access_maps
  55. parent_domain_matches_subdomains = mynetworks,permit_mx_backup_networks,smtpd_access_maps
  56. #,relay_domains
  57. mailbox_command =
  58.  
  59. smtp_sasl_path = smtp
  60. smtp_sasl_auth_enable = yes
  61. smtp_sasl_security_options = noanonymous #noplaintext
  62. smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
  63. smtpd_sender_restrictions =
  64. permit_mynetworks,
  65. reject_non_fqdn_sender,
  66. reject_unknown_sender_domain,
  67. permit
  68. sendmail_path = /usr/sbin/sendmail
  69. data_directory = /var/lib/postfix
  70.  
  71. TBH, I haven't looked at this in years, so it may not be configured optimally.
  72.  
  73. [/etc/postfix/mydestinations]
  74. /localhost/ ACCEPT
  75. /<mydomain>\.<tld>/ ACCEPT
  76. /.*\.<mydomain>\.<tld>/ ACCEPT
  77.  
  78. [/etc/postfix/relay_domains]
  79. <machinename>.<mydomain>.<tld> OK
  80. *.<mydomain>.<tld> OK
  81. <mydomain>.<tld> OK
  82.  
  83. [/etc/postfix/sasl_passwd]
  84. smtp.gmail.com:587 <gmailnick>@gmail.com:<mygmailpass>
  85.  
  86. These files need to be hashed:
  87. /usr/sbin/postmap hash:/etc/postfix/relay_domains
  88. /usr/sbin/postmap hash:/etc/postfix/mydestinations
  89. /usr/sbin/postmap hash:/etc/postfix/sasl_passwd
  90.  
  91. After changing any of these files and hashing them, you need to restart postfix to pick up the changes.
  92.  
  93. /sbin/service dovecot restart #I don't remember if this is necessary
  94. /sbin/service postfix restart
  95.  
  96. Then I run a quick php script:
  97.  
  98. <?php
  99. $to = '<mynick>@newrelic.<mydomain>.<tld>';
  100. $subject = 'Super Serious Offer';
  101. $message = 'hello there you, do you scam?';
  102. $headers = 'From: [email protected]' . "\r\n";
  103. mail($to, $subject, $message, $headers);
  104. ?>
  105.  
  106. Then I test from say a gmail or yahoo mail account. There's additional work to get gmail working, iirc.
  107.  
  108. This is also how I test blocking domains, which can be done:
  109. vi /etc/postfix/banned-regexp
  110.  
  111. /<mynick>@ably\.<mydomain>\.<tld>/ REJECT
  112.  
  113. I have lots of this. Add a line then restart postfix.
  114. /sbin/service postfix restart
  115.  
  116. Test with the php script and see if it arrives.
Advertisement
Add Comment
Please, Sign In to add comment