I'm getting

   "SASL PLAIN authentication failed"

in /var/log/mail.log

and

   "smtplib.SMTPAuthenticationError: (535, b'5.7.8 Error: authentication
failed:')"

on command line when I try to send email from a remote Python script.

I can't figure out what it is.  Do you have any suggestions on how to
slowly
debug auth issues like this?

Here is the Python script, the Python script output, the relevant mail.log
piece, main.cf,
master.cf and doveconf -n output.

Any help greatly appreciated....

=================================================================================
Python test script:
=================================================================================

import smtplib , ssl

password = "<REDACTED>"

with smtplib.SMTP("bighelp.business", 465) as server:
     server.connect("bighelp.business", 465)
     server.ehlo()
     server.starttls()
     server.login("cs@bighelp.business", password)
     server.sendmail("c...@pylayers.org" , "cseber...@gmail.com" , "I am
trying out python email through coding")


=================================================================================
Python test script output:
=================================================================================

Traceback (most recent call last):
  File "/home/cs/Ws/Wb/vv", line 9, in <module>
    server.login("cs@bighelp.business", password)
  File "/usr/lib/python3.10/smtplib.py", line 750, in login
    raise last_exception
  File "/usr/lib/python3.10/smtplib.py", line 739, in login
    (code, resp) = self.auth(
  File "/usr/lib/python3.10/smtplib.py", line 662, in auth
    raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Error: authentication
failed:')

=================================================================================
Relevant /var/log/mail.log contents:
=================================================================================

Jan  1 14:19:27 server postfix/smtpd[73750]: warning: hostname
98-96-117-129.dyn.tachusfiber.net does not resolve to address 98.96.117.129:
Name or service not known
Jan  1 14:19:27 server postfix/smtpd[73750]: connect from
unknown[98.96.117.129]
Jan  1 14:19:31 server postfix/smtpd[73750]: warning:
unknown[98.96.117.129]: SASL PLAIN authentication failed:
Jan  1 14:19:31 server postfix/smtpd[73750]: disconnect from
unknown[98.96.117.129] ehlo=2 starttls=1 auth=0/1 quit=1 commands=4/5


=================================================================================
/etc/postfix/main.cf:
=================================================================================

# Specifies domain info.
mydomain                        = pylayers.org
myhostname                      = $mydomain
myorigin                        = $mydomain
mydestination                   = $mydomain

# Configures SASL.
smtpd_sasl_auth_enable          = yes
smtpd_sasl_type                 = dovecot
smtpd_sasl_path                 = private/auth
smtpd_recipient_restrictions    =
        reject_non_fqdn_sender,
        reject_non_fqdn_recipient,
        reject_unknown_sender_domain,
        reject_unknown_recipient_domain,
        reject_unauth_pipelining,
        permit_sasl_authenticated,
        reject
mynetworks                      =

# Configures TLS.
smtpd_tls_auth_only             = yes
smtpd_tls_security_level        = encrypt
smtpd_tls_cert_file             =
/etc/letsencrypt/live/bighelp.business/fullchain.pem
smtpd_tls_key_file              =
/etc/letsencrypt/live/bighelp.business/privkey.pem
smtp_tls_security_level         = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# Sets up aliases.
alias_database                  = hash:/etc/aliases
alias_maps                      = hash:/etc/aliases


=================================================================================
/etc/postfix/master.cf:
=================================================================================

# Defines remote services
submissions       inet       n - y -     - smtpd

# Defines local services.
pickup            unix       n - y 60    1 pickup
cleanup           unix       n - y -     0 cleanup
qmgr              unix       n - n 300   1 qmgr
tlsmgr            unix       - - y 1000? 1 tlsmgr
rewrite           unix       - - y -     - trivial-rewrite
bounce            unix       - - y -     0 bounce
defer             unix       - - y -     0 bounce
trace             unix       - - y -     0 bounce
verify            unix       - - y -     1 verify
flush             unix       n - y 1000? 0 flush
proxymap          unix       - - n -     - proxymap
proxywrite        unix       - - n -     1 proxymap
smtp              unix       - - y -     - smtp
relay             unix       - - y -     - smtp
showq             unix       n - y -     - showq
error             unix       - - y -     - error
retry             unix       - - y -     - error
discard           unix       - - y -     - discard
local             unix       - n n -     - local
virtual           unix       - n n -     - virtual
anvil             unix       - - y -     1 anvil
scache            unix       - - y -     1 scache

=================================================================================
doveconf -n
=================================================================================

# 2.3.16 (7e2e900c1a): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.16 (09c29328)
# OS: Linux 5.19.0-1028-aws x86_64 Ubuntu 22.04.2 LTS
# Hostname: server
mail_location = mbox:~/mail:INBOX=/var/mail/%u
mail_privileged_group = mail
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  driver = pam
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
}
ssl_cert = </etc/dovecot/private/dovecot.pem
ssl_client_ca_dir = /etc/ssl/certs
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
userdb {
  driver = passwd
}
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org

Reply via email to