How to use mailgun with email plugin

Here’s the config:

mailer:
  engine: smtp
  smtp:
    server: smtp.mailgun.org
    port: 587
    encryption: tls
    user: 'domainname'
    password: 'apikey'

As username i’ve tried to use: my domain name in mailgun and my email in mailgun, both didn’t work. As password tried to use api key and my mailgun’s email password, both didn’t work.

Tried to change user to domain and password to secret didn’t work either. Was testing using this command:

bin/plugin email test-email -t myemail@gmail.com

This works for me.

mailer:
  engine: smtp
  smtp:
	server: smtp.mailgun.org
	port: 587
	encryption: none
	user: postmaster@sub.domain.com
	password: 'API_KEY'
  sendmail:
	bin: '/usr/sbin/sendmail -bs'
content_type: text/html
debug: false

I am getting this error:

  [Swift_TransportException]
  Failed to authenticate on SMTP server with username "postmaster@domain" using 2 possible authenticators