I'm trying to configure Postfix to only send (not receive) emails. I have followed this guide, but I didn't change my hostname
to match my domain, because if I can avoid it, I would like to do it.
So, after trying a lot, I keep receiving emails with the hostname
after the @
, and it's quite frustrating, because I have replaced all the $myhostname
variable occurrences in the /etc/postfix/main.cf
file with the domain name, but it's as if Postfix doesn't like it and continues sending emails with the hostname
attached as domain. Here's my main.cf
file:
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = example.com ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = example.com
mydestination = example.com, localhost.example.com, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all
What am I doing wrong? Do I need to tweak any other thing? Thanks in advance.
sendmail
command, you are doing it wrong.myhostname
toexample.com
if your hostname isn't actuallyexample.com
. That is, if I don't reach your machine when I typeping example.com
.echo "This is the body of the email" | mail -s "This is the subject line" [email protected]
main.cf
I have my authentic registered domain./etc/hostname
(and also/etc/mailname
). And if you want to send mail with a different envelope address you can use for examplemailx
with the-r
flag.