Symfony 1.4 send mail embed image

时间:2022-10-25 19:10:54
       $mailFrom = GrapheConfig::get('app_admin_email');
            $mailTo = $request->getParameter('email');
            $mailSubject = 'Merci pour votre pré-inscription!';
            
            /*$view = new sfPartialView($this->getContext(), $this->getModuleName(), $this->getActionName(), 'confirmMail');
            $view->setTemplate('_confirmMail.php');
            $mailBody = $view->render();*/
            
            $message = Swift_Message::newInstance();
            
            $logo = $message->embed(Swift_Image::fromPath(sfConfig::get('sf_web_dir').'/images/subscribe/bienvenue.jpg'));
       // or
       $logo = image_path('/images/pro/logo.png', true);
            $mailBody = $this->getPartial('confirmMail', compact('logo'));
            
            $message->setFrom($mailFrom)
                    ->setTo($mailTo)
                    ->setSubject($mailSubject)
                    ->setBody($mailBody);
            $message->setContentType('text/html');
            $this->getMailer()->send($message);