私は、すべてのユーザが別のユーザの電子メールを送信する機会を与える関数を作成しようとしています。これは、ではSwiftMailerの基本的なコントローラです:symfony2で電子メールを送信
public function contactAction($id)
{
$enquiry = new Enquiry();
$form = $this->createForm(new EnquiryType(), $enquiry);
$from=$this->container->get('security.context')->getToken()->getUser()->getemail();
$em=$this->getDoctrine()->getManager();
$user=$em->getRepository('PfeUserBundle:User')->findBy(array('id'=>$id));
$request = $this->getRequest();
if ($request->getMethod() == 'POST') {
$form->bind($request);
if ($form->isValid()) {
$message = \Swift_Message::newInstance()
->setSubject('Intello')
->setFrom($from)
->setTo($user->getemail())
->setBody($this->renderView('PfeUserBundle:Contact:contactEmail.txt.twig', array('enquiry' => $enquiry)));
$this->get('mailer')->send($message);
$this->get('session')->getFlashBag()->add('blogger-notice','Ton message a été envoyé avec succès');
// Redirect - This is important to prevent users re-posting
// the form if they refresh the page
return $this->redirect($this->generateUrl('pfe_intello_contact_mail'));
}
}
私はこのエラー エラーを持っている:非オブジェクト
smtpプロトコルとパスワードを設定する必要があります – ghazi2008
アップデートとはどういう意味ですか?もう何を試しましたか?あなたは文書を読んだのですか? –
@StephanVierkanどのユーザーも別のユーザーに電子メールを送信できるようにしたいが、この機能を使用すると、送信されたすべての電子メールは、パラメータで既に構成された電子メールに届きます。 yml –