Symfony2 Swiftmailer Not Sending

前端 未结 7 821
南旧
南旧 2021-02-07 04:14

I am having trouble sending emails with symfony2 and swiftmailer. I am also a bit lost on how to debug this issue. Below is the code. First I am creating a form to display. On s

相关标签:
7条回答
  • 2021-02-07 04:48

    Can you post parameters.yml?

    Also ensure that spooling is disabled so the email can be instantly sent. If you have a spool entry under the Swiftmailer configuration, delete it, for example:

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

    Should be:

    swiftmailer:
        transport: %mailer_transport%
        host:      %mailer_host%
        username:  %mailer_user%
        password:  %mailer_password%
    
    0 讨论(0)
  • 2021-02-07 04:53

    I you have trouble receiving email with ovh, siwftmailer and fosUserBundle,

    please consider adding this in your config.yml

    fos_user:
        from_email:
                address:        noreply@yourdomain.com
                sender_name:    yourname
    

    If you don't do this, fos user bundle will send the email with noreply@exemple.com and OVH flag this as spam.

    source: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/emails.md

    0 讨论(0)
  • 2021-02-07 04:55

    You may have mail spooling set. If it is a case you need to run:

    php app/console swiftmailer:spool:send
    

    to send spooled emails.

    Check http://symfony.com/doc/master/cookbook/email/spool.html for more.

    0 讨论(0)
  • 2021-02-07 04:55

    config.yml

    # Swiftmailer Configuration
    swiftmailer:
        transport:  smtp
        encryption: ssl
        auth_mode:  login
        host:       smtp.xx.eu
        username:   username
        password:   password 
    

    controller/action

    $messageObject = \Swift_Message::newInstance()
                ->setSubject('Subject')
                ->setFrom('username@xx.eu')
                ->setTo('xxx@stackoverflow.eu')
                ->setBody('message');
    $this->get('mailer')->send($messageObject);
    
    0 讨论(0)
  • 2021-02-07 04:58

    I often set the following configuration in config_dev.yml to -prevent- mails being sent during testing, maybe you have done the same and forgot?

    If this is in config_dev.yml, set it to false:

    swiftmailer:
      disable_delivery:  true
    
    0 讨论(0)
  • 2021-02-07 05:06

    You can find here the entire procedure on how to send emails with symfony2. I just tested it at it seems to work fine.

    http://tutorial.symblog.co.uk/docs/validators-and-forms.html#sending-the-email

    http://symfony.com/doc/current/email.html

    0 讨论(0)
提交回复
热议问题