title: Cannot login to SMTP server Postfix/Imap Courier/Plesk
body: <p>I have problems connecting on SMTP to the email server.</p>
  
  <p>I'm trying to send email with PHPMailer and this is the error I get:</p>
  
  <pre><code>SMTP -&gt; get_lines(): $data was ""SMTP -&gt; get_lines(): $str is "535 5.7.8 Error: authentication failed: encryption needed to use mechanism
  "SMTP -&gt; get_lines(): $data is "535 5.7.8 Error: authentication failed: encryption needed to use mechanism
  "SMTP -&gt; ERROR: AUTH not accepted from server: 535 5.7.8 Error: authentication failed: encryption needed to use mechanism
  CLIENT -&gt; SMTP: RSET
  SMTP -&gt; get_lines(): $data was ""SMTP -&gt; get_lines(): $str is "250 2.0.0 Ok
  "SMTP -&gt; get_lines(): $data is "250 2.0.0 Ok
  "SMTP -&gt; FROM SERVER:250 2.0.0 Ok
  exception 'phpmailerException' with message 'SMTP Error: Could not authenticate.' in C:\Projects\oicrm\protected\components\phpMailer\class.phpmailer
  </code></pre>
  
  <p>I have tested with another email server and it works fine, so it must be something wrong with the server configuration.</p>
  
  <p>The server is running Postfix, Courier Imap and Plesk control panel.</p>
  
  <p>Also has installed the fail2ban tool.</p>
  
  <p>Hours ago it was running Dovecot instead of Courier but I have removed it and installed Courier thinking that this will solve it but with no luck.</p>
  
  <p>I have also did tweaking to Postfix master.cf but with no luck.</p>
  
  <p>I'm thinking that the problem could be either misconfiguration in email server, or maybe ssl/auth issues on server, or maybe some firewall causing problems?</p>
  
  <p>Just tried to connect by telnet 25 and got this:  </p>
  
  <pre><code>[root@eldeposit postfix]# telnet mail.oibarcelona.com 25
  Trying xxx.xxx.140.235...
  Connected to xxx.xxxxxxxxx.com.
  Escape character is '^]'.
  220 ns334238.ip-xx-xx-xx.eu ESMTP Postfix
  EHLO ns334238.ip-xx-xx-xx.eu
  250-ns334238.ip-xx-xx-xx.eu
  250-PIPELINING
  250-SIZE 30720000
  250-ETRN
  250-STARTTLS
  250-ENHANCEDSTATUSCODES
  250-8BITMIME
  250 DSN
  AUTH LOGIN
  503 5.5.1 Error: authentication not enabled
  </code></pre>
  
  <p>Providing here my configuration:</p>
  
  <pre><code>[root@ns334238 postfix]# postconf -n
  alias_database = hash:/etc/aliases
  alias_maps = hash:/etc/aliases, hash:/var/spool/postfix/plesk/aliases
  command_directory = /usr/sbin
  config_directory = /etc/postfix
  daemon_directory = /usr/libexec/postfix
  data_directory = /var/lib/postfix
  debug_peer_level = 2
  debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id &amp; sleep 5
  disable_vrfy_command = yes
  html_directory = no
  inet_interfaces = all
  inet_protocols = all
  mail_owner = postfix
  mailbox_size_limit = 0
  mailman_destination_recipient_limit = 1
  mailq_path = /usr/bin/mailq.postfix
  manpage_directory = /usr/share/man
  message_size_limit = 30720000
  mydestination = localhost.$mydomain, localhost, localhost.localdomain
  myhostname = ns334238.ip-37-187-140.eu
  mynetworks =
  newaliases_path = /usr/bin/newaliases.postfix
  plesk_virtual_destination_recipient_limit = 1
  queue_directory = /var/spool/postfix
  readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
  sample_directory = /usr/share/doc/postfix-2.10.1/samples
  sender_dependent_default_transport_maps = hash:/var/spool/postfix/plesk/sdd_transport_maps
  sendmail_path = /usr/sbin/sendmail.postfix
  setgid_group = postdrop
  smtp_send_xforward_command = yes
  smtp_tls_security_level = may
  smtp_use_tls = no
  smtpd_authorized_xforward_hosts = 127.0.0.0/8 [::1]/128
  smtpd_client_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_rbl_client zen.spamhaus.org
  smtpd_milters = , inet:127.0.0.1:12768
  smtpd_proxy_timeout = 3600s
  smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
  smtpd_sasl_auth_enable = yes
  smtpd_sasl_security_options = noplaintext
  smtpd_sender_restrictions = check_sender_access hash:/var/spool/postfix/plesk/blacklists, permit_sasl_authenticated
  smtpd_timeout = 3600s
  smtpd_tls_auth_only = yes
  smtpd_tls_cert_file = /etc/pki/ns334238.ip-37-187-140.eu.pem
  smtpd_tls_ciphers = medium
  smtpd_tls_exclude_ciphers = aNULL
  smtpd_tls_key_file = $smtpd_tls_cert_file
  smtpd_tls_protocols = SSLv3, TLSv1
  smtpd_tls_security_level = may
  smtpd_use_tls = yes
  transport_maps = , hash:/var/spool/postfix/plesk/transport
  unknown_local_recipient_reject_code = 550
  virtual_alias_maps = $virtual_maps, hash:/var/spool/postfix/plesk/virtual
  virtual_gid_maps = static:31
  virtual_mailbox_base = /var/qmail/mailnames
  virtual_mailbox_domains = $virtual_mailbox_maps, hash:/var/spool/postfix/plesk/virtual_domains
  virtual_mailbox_limit = 0
  virtual_mailbox_maps = , hash:/var/spool/postfix/plesk/vmailbox
  virtual_transport = plesk_virtual
  virtual_uid_maps = static:30
  postconf: warning: /etc/postfix/main.cf: unused parameter: tls_ssl_options=NO_COMPRESSION
  </code></pre>
  
  <p>And another one:  </p>
  
  <pre><code>[root@ns334238 postfix]# postconf -M
  smtp       inet  n       -       n       -       -       smtpd
  pickup     unix  n       -       n       60      1       pickup
  cleanup    unix  n       -       n       -       0       cleanup
  qmgr       unix  n       -       n       300     1       qmgr
  tlsmgr     unix  -       -       n       1000?   1       tlsmgr
  rewrite    unix  -       -       n       -       -       trivial-rewrite
  bounce     unix  -       -       n       -       0       bounce
  defer      unix  -       -       n       -       0       bounce
  trace      unix  -       -       n       -       0       bounce
  verify     unix  -       -       n       -       1       verify
  flush      unix  n       -       n       1000?   0       flush
  proxymap   unix  -       -       n       -       -       proxymap
  proxywrite unix  -       -       n       -       1       proxymap
  smtp       unix  -       -       n       -       -       smtp
  relay      unix  -       -       n       -       -       smtp
  showq      unix  n       -       n       -       -       showq
  error      unix  -       -       n       -       -       error
  retry      unix  -       -       n       -       -       error
  discard    unix  -       -       n       -       -       discard
  local      unix  -       n       n       -       -       local
  virtual    unix  -       n       n       -       -       virtual
  lmtp       unix  -       -       n       -       -       lmtp
  anvil      unix  -       -       n       -       1       anvil
  scache     unix  -       -       n       -       1       scache
  plesk_virtual unix -     n       n       -       -       pipe flags=DORhu user=popuser:popuser argv=/usr/lib64/plesk-9.0/postfix-local -f ${sender} -d ${recipient} -p /var/qmail/mailnames
  mailman    unix  -       n       n       -       -       pipe flags=R user=mailman:mailman argv=/usr/lib64/plesk-9.0/postfix-mailman ${nexthop} ${user} ${recipient}
  pickup     fifo  n       -       n       60      1       pickup
  plesk_saslauthd unix y   y       n       -       1       plesk_saslauthd status=5 listen=6 dbpath=/var/spool/postfix/plesk/passwd.db
  qmgr       fifo  n       -       n       1       1       qmgr
  smtps      inet  n       -       n       -       -       smtpd -o smtpd_tls_wrappermode=yes
  submission inet  n       -       n       -       -       smtpd -o smtpd_enforce_tls=no -o smtpd_tls_security_level=may -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_mynetworks,permit_sasl_authenticated,reject -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
  plesk-example-domainbarcelona.com-XXX.XXX.XXX.XXX- unix - n n - -     smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainbarcelona.com
  plesk-example-domaintrend.com-XXX.XXX.XXX.XXX- unix - n n -   -       smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domaintrend.com
  plesk-example-domaintrend.com-XXX.XXX.XXX.XXX- unix - n n -  -       smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domaintrend.com
  plesk-example-domainbarcelona.fr-XXX.XXX.XXX.XXX- unix - n n -  -       smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainbarcelona.fr
  plesk-example-domainbarcelona.co.uk-XXX.XXX.XXX.XXX- unix - n n - -     smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainbarcelona.co.uk
  plesk-example-domainbarcelona.de-XXX.XXX.XXX.XXX- unix - n n - -       smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainbarcelona.de
  plesk-example-domainmallorca.com-XXX.XXX.XXX.XXX- unix - n n - -      smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainmallorca.com
  plesk-example-domainmgzn.com-XXX.XXX.XXX.XXX- unix - n n -    -       smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6= -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainmgzn.com
  plesk-example-domainmallorca.com-XXX.XXX.XXX.XXX-2001-41d0-a-4aeb-- unix - n n - - smtp -o smtp_bind_address=XXX.XXX.XXX.XXX -o smtp_bind_address6=2001:41d0:a:4aeb:: -o smtp_address_preference=ipv4 -o smtp_helo_name=example-domainmallorca.com
  </code></pre>