213144f0315965342c9b0fcb796486215c5dc720
By:
writegnj

Postfix can't send email to the same domain name email address as the droplet

February 23, 2017 926 views
Email PHP WordPress Ubuntu

I have been researching for 3days but haven't find the solution for this email issue.

I use Postfix to send out email on my droplet which is working fine for all email addresses but not for the email address that I assigned to the droplet. I have tried http://stackoverflow.com/questions/18377813/postfix-status-bounced-unknown-user-myuser and all other suggestions I found online but nothing worked.

Here is my etc/postfix/main.cf

# 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 = $myhostname 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

# 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 = goodnightjournal.com
alias_maps = hash:/etc/aliases
# virtual_alias_maps = hash:/etc/postfix/virtual
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = 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

and I'm getting this error message on sending email to o@goodnightjournal.com from my contact form on the site.

Feb 23 01:30:41 goodnightjournal postfix/pickup[17494]: 492A4185557: uid=33 from=<www-data>
Feb 23 01:30:41 goodnightjournal postfix/cleanup[17713]: 492A4185557: message-id=<d2b17d8f8fb99f252a50a823d0e8cbdb@goodnightjournal.com>
Feb 23 01:30:41 goodnightjournal postfix/qmgr[17105]: 492A4185557: from=<www-data@104.236.98.136>, size=706, nrcpt=1 (queue active)
Feb 23 01:30:41 goodnightjournal postfix/smtp[17715]: 492A4185557: to=<o@goodnightjournal.com>, relay=smtp.secureserver.net[68.178.213.203]:25, delay=0.48, delays=0.01/0/0.21/0.25, dsn=5.2.0, status=bounced (host smtp.secureserver.net[68.178.213.203] said: 550 5.2.0 <www-data@104.236.98.136> From: Domain is invalid. Please provide a valid From: IB506  <http://x.co/srbounce> (in reply to end of DATA command))
Feb 23 01:30:41 goodnightjournal postfix/cleanup[17713]: BEB9D185558: message-id=<20170223063041.BEB9D185558@goodnightjournal.com>
Feb 23 01:30:41 goodnightjournal postfix/qmgr[17105]: BEB9D185558: from=<>, size=2817, nrcpt=1 (queue active)
Feb 23 01:30:41 goodnightjournal postfix/bounce[17716]: 492A4185557: sender non-delivery notification: BEB9D185558
Feb 23 01:30:41 goodnightjournal postfix/qmgr[17105]: 492A4185557: removed
Feb 23 01:30:41 goodnightjournal postfix/error[17718]: BEB9D185558: to=<www-data@104.236.98.136>, relay=none, delay=0.02, delays=0.01/0.01/0/0, dsn=5.1.3, status=bounced (bad address syntax)
Feb 23 01:30:41 goodnightjournal postfix/qmgr[17105]: BEB9D185558: removed
6 comments
  • Change the following two lines

    myhostname = SERVERNAME.goodnightjournal.com
    mydestination = $myhostname
    

    Where SERVERNAME is whatever you call your server.

  • Thank you for the comment @hansen
    SERVERNAME is the same as what I get from hostname -f? It's goodnightjournal.com for me.

    Didn't seem like working still getting error below.

    Feb 23 18:38:04 goodnightjournal postfix/pickup[27416]: D538D185609: uid=33 from=<www-data>
    Feb 23 18:38:04 goodnightjournal postfix/cleanup[27422]: D538D185609: message-id=<389a5174f3adc2abd36856e97ca1c037@goodnightjournal.com>
    Feb 23 18:38:04 goodnightjournal postfix/qmgr[27417]: D538D185609: from=<www-data@104.236.98.136>, size=730, nrcpt=1 (queue active)
    Feb 23 18:38:05 goodnightjournal postfix/smtp[27424]: D538D185609: to=<o@goodnightjournal.com>, relay=smtp.secureserver.net[72.167.238.29]:25, delay=0.6, delays=0.02/0.02/0.27/0.29, dsn=5.2.0, status=bounced (host smtp.secureserver.net[72.167.238.29] said: 550 5.2.0 <www-data@104.236.98.136> From: Domain is invalid. Please provide a valid From: IB506  <http://x.co/srbounce> (in reply to end of DATA command))
    Feb 23 18:38:05 goodnightjournal postfix/cleanup[27422]: 7404618560A: message-id=<20170223233805.7404618560A@goodnightjournal.com.goodnightjournal.com>
    Feb 23 18:38:05 goodnightjournal postfix/bounce[27425]: D538D185609: sender non-delivery notification: 7404618560A
    Feb 23 18:38:05 goodnightjournal postfix/qmgr[27417]: 7404618560A: from=<>, size=3029, nrcpt=1 (queue active)
    Feb 23 18:38:05 goodnightjournal postfix/qmgr[27417]: D538D185609: removed
    Feb 23 18:38:05 goodnightjournal postfix/error[27426]: 7404618560A: to=<www-data@104.236.98.136>, relay=none, delay=0.01, delays=0/0/0/0, dsn=5.1.3, status=bounced (bad address syntax)
    Feb 23 18:38:05 goodnightjournal postfix/qmgr[27417]: 7404618560A: removed
    
  • Normally you would have a hostname for your server, which is part of a domain, which then is part of a TLD.
    One of my servers is called Maria, so then I would have the FQDN looking like maria.goodnightjournal.com
    Because your server is actually not managing mail, but just relaying it, then you cannot use goodnightjournal.com as myhostname/mydestination, since it will swallow all mail being sent from the server to whatever@goodnightjournal.com and not relaying it.

  • @hansen I don't think I'm fully following :( It seems like Postfix is sending out the email but my Godaddy email is bouncing the email cause it's coming from from=<www-data@104.236.98.136> . Godaddy says that Verify that you are sending from a valid domain. Then verify that the domain has valid DNS records by doing an external DNS lookup. If the DNS isn't valid, it must be fixed before you resend the email. Do you know how to change from=<www-data@104.236.98.136> to from=<www-data@goodnightjounrnal.com>? I think this might solve the issue.

  • Log in to https://cloud.digitalocean.com/networking/ptr and your rDNS to goodnightjournal.com. - wait a few hours (maybe a day) and try again.
    And while you're at it, you should probably setup SPF for your domain to tell others that your server is allowed to send email as goodnightjournal.com.
    https://www.digitalocean.com/community/tutorials/how-to-create-a-spf-record-for-your-domain-with-google-apps
    EDIT: Not that you have Google Apps, but just as a reference guide.

    by Keshav Pareek
    Here we'll show you how to create a SPF record for your domain with Google Apps.
  • Thank you again for the answer. I actually had them set up the way to suggested already. I feel like totally lost now..

1 Answer
Have another answer? Share your knowledge.