In order to avoid spam sent from my server I'm trying to get Postfix to block all outgoing emails, except the ones sent from specific email address (like [email protected]), and allow all incoming emails to all addresses listed in a mysql db.
I managed to configure the imcoming part, but I'm struggling to block the outgoing emails.
How do I do that? Is there a way I can test if the server actually block outgoing emails? How do the spammers do? Can I check at the logs?
Edit. This is my current configuration:
compatibility_level = 3.6
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
unknown_local_recipient_reject_code = 550
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /etc/postfix
readme_directory = /usr/share/doc/postfix/readme
inet_protocols = ipv4
meta_directory = /etc/postfix
shlib_directory = /usr/lib/postfix
maillog_file = /dev/stdout
myhostname = mydomain.com
mydomain = mydomain.com
mydestination = mydomain.com, localhost.localdomain, localhost
myorigin = $mydomain
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
always_add_missing_headers = yes
smtp_host_lookup = native,dns
transport_maps = lmdb:/dockervolume/transport
virtual_alias_maps = proxy:mysql:/dockervolume/mysql-virtual_email2email.cf
virtual_mailbox_maps = proxy:mysql:/dockervolume/mysql-virtual_mailboxes.cf
local_recipient_maps = $virtual_mailbox_maps
local_transport = virtual
relay_domains = $mydomain
smtpd_banner = $mydomain
default_process_limit = 100
smtpd_client_connection_count_limit = 10
smtpd_client_connection_rate_limit = 10
queue_minfree = 20971520
header_size_limit = 51200
message_size_limit = 2097152
smtpd_recipient_limit = 5
disable_vrfy_command = yes
smtpd_helo_required = yes
mynetworks = 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
smtp_tls_loglevel = 1
smtpd_tls_loglevel = 1
smtpd_client_message_rate_limit = 5
anvil_rate_time_unit = 120s
smtpd_client_recipient_rate_limit = 10
smtpd_tls_auth_only = yes
smtpd_delay_reject = yes
smtpd_helo_restrictions = permit
smtpd_error_sleep_time = 3s
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 20
default_destination_rate_delay = 2s
smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unknown_sender_domain, permit
smtpd_recipient_restrictions = permit_mynetworks, reject_unknown_recipient_domain, permit