[Symfony 2] Switmailer et ovh
Bonjour, après de nombreuses recherches, l'envoie de mail à partir d'un formulaire de contact ne fonctionne pas. Je suis sur un mutualisé Ovh offre pro.
Les tests effectués en prod sur le serveur
Me voilà bloquer avec l'erreur suivante :
[2015-02-02 12:03:30] request.INFO: Matched route "mariage_fo_contact" (parameters: "_controller": "Mariage\FoBundle\Controller\ContactController::indexAction", "_route": "mariage_fo_contact") [] []
[2015-02-02 12:03:30] security.DEBUG: Read SecurityContext from the session [] []
[2015-02-02 12:03:30] security.DEBUG: Reloading user from user provider. [] []
[2015-02-02 12:03:30] security.DEBUG: Username "uploader" was reloaded from user provider. [] []
[2015-02-02 12:03:31] security.DEBUG: Write SecurityContext in the session [] []
[2015-02-02 12:03:36] app.ERROR: Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "XXXXXXXXXX" using 1 possible authenticators [] []
mon controller
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| <?php
namespace Mariage\FoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Mariage\FoBundle\Form\ContactType;
class ContactController extends Controller
{
public function indexAction(Request $request) {
$form = $this->createForm(new ContactType(), null, array(
'action' => $this->generateUrl('mariage_fo_contact'),
'method' => 'POST'
));
$form->add('valider', 'submit', array("attr" =>array('class' => 'form_submit_contact','label' => 'Valider')));
$form->handleRequest($request);
if ($form->isValid()) {
$data = $form->getData();
$message = \Swift_Message::newInstance()
->setSubject('Mariage')
//->setFrom('expediteur@nomdedomaine.fr')
->setTo('destinataire@gmail.com')
->setBody($this->renderView('MariageFoBundle:Email:email.txt.twig', array('nom' => $data['nom'],'prenom' => $data['prenom'],'email'=> $data['email'],'tel'=> $data['tel'],'message' => $data['message'])));
$this->get('mailer')->send($message);
return $this->redirect($this->generateUrl('mariage_fo_homepage'));
}
return $this->render('MariageFoBundle:Contact:contact.html.twig',
array(
'form' => $form -> createView())
);
}
} |
mon config.yml
Code:
1 2 3 4 5 6 7 8
| swiftmailer:
transport: "%mailer_transport%"
auth_mode: "%mailer_auth_mode%"
host: "%mailer_host%"
port: "%mailer_port%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory } |
mon parameters.yml
Code:
1 2 3 4 5 6
| mailer_transport: smtp
mailer_auth_mode: login
mailer_host: smtp.nomdedomaine.fr
mailer_port: 587
mailer_user: user@nomdedomaine.fr
mailer_password: monpass |