Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure this bundle in Symfony 4? #74

Open
Jeeppler opened this issue Oct 9, 2018 · 7 comments
Open

How to configure this bundle in Symfony 4? #74

Jeeppler opened this issue Oct 9, 2018 · 7 comments

Comments

@Jeeppler
Copy link

Jeeppler commented Oct 9, 2018

Could you provide some information in the README.md on how to configure this bundle in Symfony 4?

Until now I run into the same issue as others have:

However, I think the easiest solution for most of those problems would probably be to add an example configuration for Symfony 4 in the README.md.

@fluchi
Copy link
Contributor

fluchi commented Oct 10, 2018

Hi @Jeeppler,
Setting up this on Symfony 4 is slight different.

  1. Add you Mailgun credentials on .env.dist (add the same lines on .env, just in case)
MAILGUN_DOMAIN=<your domain>
MAILGUN_API_KEY=<your key>
MAILGUN_SENDER=<your sender>

  1. Adding on AppKernel, now config/bundles.php
    cspoo\Swiftmailer\MailgunBundle\cspooSwiftmailerMailgunBundle::class => ['all' => true],

  2. Configuring credentials:
    Create a new config file on config/packages/mailgun.yaml (if it's not there) and copy the following lines:

cspoo_swiftmailer_mailgun:
    key: '%env(MAILGUN_API_KEY)%'
    domain: "%env(MAILGUN_DOMAIN)%"

services:
    Mailgun\Mailgun:
        class: Mailgun\Mailgun
        factory: ['Mailgun\Mailgun', create]
        arguments: ['%env(MAILGUN_API_KEY)%']
  1. Add the following line on config/packages/swiftmailer:
swiftmailer:
    # url: '%env(MAILER_URL)%'
    transport: 'mailgun'
    spool: { type: 'memory' }

p.s.: Not sure if you really have to comment url

  1. Test your setup with the following command on your terminal:
    bin/console swiftmailer:email:send --from=<from email> --to=<to email> --subject="Foo" --body="Bar"

With this setup, I've made it work.
Let me know if I miss something on it.

Felipe

@Jeeppler
Copy link
Author

@fluchi thank you. Awesome. Do you want add your explanation to the README.md (create pull request)?

@PhongNguyen512
Copy link

@fluchi I'm not sure about my situation, but after I installed the bundle. In my config directory, it just add mailgun.yaml. I can't find any find like swiftmailer.yaml or swiftmail.* .So my site is crashing now. Not sure what to do

@fluchi
Copy link
Contributor

fluchi commented Nov 10, 2018

@PhongNguyen512, try to create those files manually. On my case, they weren't create via composer due to permission issues (if I'm non mistaken). Then I've create them manually and everything works fine.

@PhongNguyen512
Copy link

PhongNguyen512 commented Nov 11, 2018

@fluchi Before I posted my question, I also tried to create swiftmailer.yaml file in config/packages. But I got another error
There is no extension able to load the configuration for "swiftmailer" (in /home/vagrant/code/project1/config/packages/swiftmailer.yaml). Looked for namespace "swiftmailer", found "framework", "web_profiler", "twig", "monolog", "debug", "sensio_framework_extra", "security", "doctrine_cache", "do ctrine", "doctrine_migrations", "maker", "cspoo_swiftmailer_mailgun"

I also check in vendor/ . I saw cspoo, swiftmailer and mailgun directories in there. I'm not sure where did I go wrong.

@infomaniac50
Copy link

p.s.: Not sure if you really have to comment url

If MAILER_URL is equal to null://localhost then it will definitely interfere.

@PhongNguyen512
Copy link

@infomaniac50 I already solved this issue. In my case, I install swiftmailer first I install this bundle. I think the swiftmailer in this bundle does not exist. Therefore, I install swiftmailer first and it works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants