2016-11-05 28 views
0

Symfony 3.1とSwiftMailerを使用してテスト電子メールを送信したかったのですが、動作しません。私は他のソリューションを読んでいましたが、それでも機能しません。Symfony 3.1 swiftmailerのメールは送信されません

Config.yml:

swiftmailer: 
    transport: %mailer_transport% 
    encryption: %mailer_encryption% 
    auth_mode: %mailer_auth_mode% 
    host:  %mailer_host% 
    username: %mailer_user% 
    password: %mailer_password% 
    spool:  { type: memory } 

Parameters.yml私がしようとしていた

mailer_transport: smtp 
    mailer_encryption: ssl 
    mailer_auth_mode: login 
    mailer_host: smtp.gmail.com 
    mailer_user: [email protected] 
    mailer_password: mypass 

Parameters.yml v.2の:

mailer_transport: gmail 
     mailer_encryption: ssl 
     mailer_auth_mode: login 
     mailer_host: smtp.gmail.com 
     mailer_user: [email protected] 
     mailer_password: mypass 

コントローラー:

public function contactAction(Request $request) 
    { 
     $name = $request->request->get('name'); 
     $surname = $request->request->get('surname'); 
     $email = $request->request->get('email'); 
     $subject = $request->request->get('subject'); 
     $message = $request->request->get('message'); 
     $data = ""; 
     if($request->request->get('contact_submit')){ 

      $message = \Swift_Message::newInstance() 
       ->setSubject($subject) 
       ->setFrom($email) 
       ->setTo('[email protected]') 
       ->setBody($message); 

      $this->get('mailer')->send($message); 

      $data = "Thank you: $name"; 

     } 
     return $this->render('przedszkole/contact.html.twig', array('data' => $data));  
    } 

そう後、Submitを私の見解の変更をクリックして、私を見る:あなたの$名をありがとうございました、しかし、私はすべての電子メールを得ることはありません:/

誰かが他のソリューションに言うように、私は自分のGmailのメールのセキュリティLVLを変更しかし、それは私のために助けにはなりません:/

私はまた、config_dev.ymlのdelivery_adressのコメントを解除します。

私は任意の助けのために感謝するでしょう:私はあなたがする必要はありませんデフォルト設定があることを読ん

mailer_transport: gmail 
    mailer_user: [email protected] 
    mailer_password: mypass 

:どのように(のみ)は以下のYMLの設定を使用する程度/

+0

ここで解説した解決策を試しましたか:http://stackoverflow.com/questions/3478906/using-phps-swiftmailer-with-gmail – LBA

+0

どのバージョンのPHPを使用していますか?サーバーログやSymfonyツールバーに関連するエラーが表示されますか? –

+0

PHP 5.6.23。私はどこにでもエラーが表示されません。 – Abdulos

答えて

0

Gmailのために設定して、多分あなたが設定しているので、それはいくつかの効果があります。これで問題が解決するかどうかはわかりませんが、試してみてください。

+0

それは助けにはならない:/ – Abdulos

0

私は、電子メールがスプールキューに入っていることが原因で問題が発生している可能性があります。これは他の誰かにも見られました。あなたは明示的に使用して、それを無効にすることができます。

spool: 
    enabled: false 
0

私はあなたのコードをデバッグする機会を持って、私が得るすべては、あなたがこの2行

->setFrom($email) 
->setTo('[email protected]') 

setFrom()

->setFrom('[email protected]') 
->setTo($email) 

などを変更する必要がありますあなたの電子メールIDが含まれ、 setTo()には受信者IDが含まれます。

関連する問題