3

I run a debian 7 system and I run postfix as smtp server. I can send mail from postfix to outside (even though it gets to spam folders by google) but when I try to send a mail from, lets say my google account to my server I get error.

Lets say my ip is 77.77.77.77, my hostname machine.host.org and the dns: example.ru I get this error from google:

Delivery to the following recipient failed permanently:

     testmail@example.ru

Technical details of permanent failure: 
Google tried to deliver your message, but it was rejected by the server for the recipient domain example.ru by machine.host.org. [77.77.77.77].

The error that the other server returned was:
554 5.7.1 <testmail@l2theweek.ru>: Relay access denied

My main.cf is:

#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
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

# SSL/TLS certificates
smtpd_tls_cert_file=/etc/ssl/certs/mailcert.pem
smtpd_tls_key_file=/etc/ssl/private/mail.key
smtpd_use_tls = yes
smtpd_tls_auth_only = yes

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

# Hostname and domain name
myhostname = machine.host.org
mydomain = host.org
myorigin = /etc/mailname

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname localhost.$mydomain $mydomain
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 example.ru
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all

# Anti-SPAM rules adapted from https://wiki.debian.org/Postfix
smtpd_recipient_restrictions = permit_sasl_authenticated,
        permit_mynetworks,
        check_policy_service unix:private/policy-spf,
        reject_invalid_hostname,
        reject_unknown_recipient_domain,
        reject_unauth_destination,
        reject_rbl_client sbl.spamhaus.org,
        permit

smtpd_helo_restrictions = reject_invalid_helo_hostname,
        reject_non_fqdn_helo_hostname,
        reject_unknown_helo_hostname

smtpd_client_restrictions = reject_rbl_client dnsbl.sorbs.net

# Mail will be stored in users ~/Maildir directories
home_mailbox = Maildir/
mailbox_command =

# From http://wiki2.dovecot.org/HowTo/PostfixAndDovecotSASL
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

# This changed the ups the policy time limit so the policy server won't time out while a message is still being processed.
policy-spf_time_limit = 3600s

# for OpenDKIM from https://tipstricks.itmatrix.eu/installing-opendkim-in-debian-squeeze/
milter_default_action = accept
milter_protocol = 6
smtpd_milters = inet:localhost:12345

My master.cf is:

# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -       -       -       -       smtpd
#smtp      inet  n       -       -       -       1       postscreen
#smtpd     pass  -       -       -       -       -       smtpd
#dnsblog   unix  -       -       -       -       0       dnsblog
#tlsproxy  unix  -       -       -       -       0       tlsproxy
submission inet n       -       -       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       -       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  -o milter_macro_daemon_name=ORIGINATING
#628       inet  n       -       -       -       -       qmqpd
pickup    fifo  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      fifo  n       -       n       300     1       qmgr
#qmgr     fifo  n       -       n       300     1       oqmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
smtp      unix  -       -       -       -       -       smtp
relay     unix  -       -       -       -       -       smtp
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
#   lmtp    cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
#  mailbox_transport = lmtp:inet:localhost
#  virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -       n       n       -       -       pipe
#  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix  -       n       n       -       -       pipe
#  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=email:email argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}

policy-spf  unix  -       n       n       -       -       spawn
     user=nobody argv=/usr/bin/policyd-spf

And the log from /var/log/mail.log is:

Jan  6 16:20:41 vps127955 postfix/smtpd[16499]: connect from mail-we0-f170.google.com[1.1.1.1]
Jan  6 16:20:43 vps127955 policyd-spf[16501]: None; identity=helo; client-ip=1.1.1.1; helo=mail-we0-f170.google.com; envelope-from=mymail@gmail.com; receiver=testmail@example.ru
Jan  6 16:20:43 vps127955 policyd-spf[16501]: Pass; identity=mailfrom; client-ip=1.1.1.1; helo=mail-we0-f170.google.com; envelope-from=mymail@gmail.com; receiver=testmail@example.ru
Jan  6 16:20:43 vps127955 postfix/smtpd[16499]: NOQUEUE: reject: RCPT from mail-we0-f170.google.com[1.1.1.1]: 554 5.7.1 <testmail@example.ru>: Relay access denied; from=<mymail@gmail.com> to=<testmail@example.ru> proto=ESMTP helo=<mail-we0-f170.google.com>
Jan  6 16:20:43 vps127955 postfix/smtpd[16499]: disconnect from mail-we0-f170.google.com[1.1.1.1]

How can I solve this problem?

EDIT 1: When I try to send from testmail@example.ru to testmail@example.ru the mail is not delivered and I get this:

Jan  6 17:09:22 vps127955 postfix/smtpd[16675]: A00BF2C00CBE: client=localhost[::1]
Jan  6 17:09:27 vps127955 postfix/cleanup[16685]: A00BF2C00CBE: message-id=<20150106150922.A00BF2C00CBE@machine.host.org>
Jan  6 17:09:27 vps127955 postfix/qmgr[16476]: A00BF2C00CBE: from=<testmail@example.ru>, size=354, nrcpt=1 (queue active)
Jan  6 17:09:27 vps127955 postfix/smtp[16686]: A00BF2C00CBE: to=<testmail@example.ru>, relay=none, delay=13, delays=13/0.03/0.02/0, dsn=5.4.6, status=bounced (mail for example.ru loops back to myself)
Jan  6 17:09:27 vps127955 postfix/cleanup[16685]: E5DB12C00CC1: message-id=<20150106150927.E5DB12C00CC1@machine.host.org>
Jan  6 17:09:27 vps127955 postfix/qmgr[16476]: E5DB12C00CC1: from=<>, size=2549, nrcpt=1 (queue active)
Jan  6 17:09:27 vps127955 postfix/bounce[16687]: A00BF2C00CBE: sender non-delivery notification: E5DB12C00CC1
Jan  6 17:09:27 vps127955 postfix/qmgr[16476]: A00BF2C00CBE: removed
Jan  6 17:09:27 vps127955 postfix/smtp[16686]: E5DB12C00CC1: to=<testmail@example.ru>, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=5.4.6, status=bounced (mail for example.ru loops back to myself)
Jan  6 17:09:27 vps127955 postfix/qmgr[16476]: E5DB12C00CC1: removed

but when I try to send from testmail@machine.host.org to testmail@machine.host.org the mail is delivered and I get this

Jan  6 17:10:52 vps127955 postfix/smtpd[16675]: 1E2762C00CBE: client=localhost[::1]
Jan  6 17:10:57 vps127955 postfix/cleanup[16685]: 1E2762C00CBE: message-id=<20150106151052.1E2762C00CBE@machine.host.org>
Jan  6 17:10:57 vps127955 opendkim[14116]: 1E2762C00CBE: no signing table match for 'testmail@machine.host.org'
Jan  6 17:10:57 vps127955 opendkim[14116]: 1E2762C00CBE: no signature data
Jan  6 17:10:57 vps127955 postfix/qmgr[16476]: 1E2762C00CBE: from=<testmail@machine.host.org>, size=368, nrcpt=1 (queue active)
Jan  6 17:10:58 vps127955 postfix/local[16690]: 1E2762C00CBE: to=<testmail@machine.host.org>, relay=local, delay=17, delays=16/0.14/0/0.01, dsn=2.0.0, status=sent (delivered to maildir)
Jan  6 17:10:58 vps127955 postfix/qmgr[16476]: 1E2762C00CBE: removed
  • What happens if you send an email to host.org from host.org? – eyoung100 Jan 6 '15 at 15:05
  • @eyoung100 I edited my post to answer your question. – TheCrafter Jan 6 '15 at 15:14
2

In main.cf I changed the line

mydestination = $myhostname localhost.$mydomain $mydomain

into the line

mydestination = $myhostname localhost.$mydomain $mydomain example.ru

Now everything seem to work fine. However, if someone knows what the actual cause of the problem is, please enlighten us!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.