0

i use Symfony2, and i need to send Email from my application.

in my config.yml:

swiftmailer:
transport:  smtp
encryption: ssl
auth_mode:  login
host:       smtp.gmail.com

in my config_dev.yml:

swiftmailer:
transport: gmail

When i add the Email and the password it works but i don't want to send from static Email

in my Controller i have this:

$message = \Swift_Message::newInstance()
                                    ->setSubject('demande de conge ')
                                    ->setFrom($col->getEmailCollaborateur())
                                    ->setTo($form->get("emailcdp")->getData())
                                    ->setBody($this->render('acmeBundle:Conge:demandeCongeNormal.html.twig', array('conge' => $conge, 'id'=> $this->getUser()->getId())))
                                    ;
                                    $this->get('mailer')->send($message);

i have this exception :

   Expected response code 250 but got code "530", with message "530-5.5.1 

Authentication Required. Learn more at
530 5.5.1 http://support.google.com/mail/bin/answer.py?answer=14257 o10sm16197wia.0 - gsmtp
lala
  • 111
  • 1
  • 3
  • 11

1 Answers1

1

You have an indentation error in your yaml file, there is no link between your description & your error message ! Try to add 2 spaces before "transport", in your config_dev.yml.

Take care too, gmail requires an authentication !

# Swiftmailer Configuration
swiftmailer:
    transport: "transport_value"
    username:  "username_value"
    password:  "passsssword_value"

Edit :

In addition, with gmail you can't send an email using an different mail than the linked account

Fabien MEYNARD
  • 597
  • 4
  • 12
  • when i add the username and password it works but the problem that i want to send from different Email the message !! is there any solution(without authentication). – lala Aug 25 '14 at 10:18