Bonjour,

C'est pour envoyer des mails avec des images 'embeded".

Le problème c'est qu'il me dit qu'il ne trouve pas la variable alors qu'il trouve bien une au dessus ?

Controller :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
$this->service->sendApportPerduMessage("paul.borel@gmail.com", array(
                    'baseUrl' => $baseUrl,
                    'ref_apport' => $ref_apport,
                    'slogan' => $slogan
        ));
Service :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
public function sendApportPerduMessage($to, array $params) {
        $subject = "Du nouveau concernant votre apport Veiller sur mes parents";
        $template = "ApiBundle:Cabestan:apport.perdu.mail.html.twig";
 
 
 
        //$body = $this->templating->render($template, $params);
 
        $this->sendMessage($to, $subject, $template, $params);
    }
 
protected function sendMessage($to, $subject, $template, array $params) {
        try {
            $mail = \Swift_Message::newInstance();
 
            $params["header_src"] = $mail->embed(\Swift_Image::fromPath('bundles/back/images/mail_apport.png'));
            $params["footer_src"] = $mail->embed(\Swift_Image::fromPath('bundles/back/images/logo_vsmp.png'));
 
            $body = $this->templating->render($template, $params);
 
            //var_dump($params);die;
 
            $mail->setBody(
                $body
            );
 
            $mail
                    ->setFrom($this->from)
                    ->setTo($to)
                    ->setSubject($subject)
                    //->setBody($body)
                    ->setContentType("text/html");
 
            $response = $this->mailer->send($mail);
        } catch (\Exception $ex) {
            return $ex->getMessage();
        }
    }
Twig :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
<div class="container">{{ include('ApiBundle:Cabestan:header.mail.html.twig', { 'header_src': header_src }) }}
Il me dit qu'il trouve pas la variable "header_src".

Une idée ?

Merci