If you get this error message while sending an email using swiftmailer in symfony

14:54:30 ERROR [app] Exception occurred while flushing email queue: Expected response code 250 but got code “530”, with message “530 5.7.0 Must issue a STARTTLS command first. a6sm43709402wrp.49 – gsmtp

so to resolve the problem try to use this configuration:

in parameters.yml

mailer_encryption: ssl
mailer_auth_mode: login
mailer_transport: gmail
mailer_host: smtp.gmail.com
mailer_user: ***@gmail.com
mailer_password: ******

in config.yml

swiftmailer:
transport: %mailer_transport%
encryption: %mailer_encryption%
auth_mode: %mailer_auth_mode%
host: %mailer_host%
username: %mailer_username%
password: %mailer_password%
spool: { type: memory }