Symfony 3 and Mailhog: mails not being cached by mailhog











up vote
2
down vote

favorite












In my dev enviroment I want to use mailhog to catch the emails. I've installed and configure my php.ini to sustitute the sendmail property.
If in command line i run this



php -r "mail(......);" 


the mail gets captured by mailhog. The problem is with Symfony and Swiftmailer. To make a test i created a very simple controller with this:



/**
* @return Response
*/
public function homeAction() : Response
{
mail('some@mail.com', 'tasest', 'aaaa');
$message = Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send@example.com')
->setTo('recipient@example.com')
->setBody(
'aaaaa',
'text/html'
);
$this->get('mailer')->send($message);
return $this->render('::base.html.twig');
}


Now, the email sent by the mail function gets captured by mailhog. But not the mail sent by SwiftMailer.



In my config_dev I have this:



    # Swiftmailer Configuration
swiftmailer:
transport: "sendmail"


which I think should be enough.



Am I missing something here?



P.S.: If i use a real address (instead of recipient@example.com) the email gets sent and received



Update:
I also tried to configure mailhog for smtp, parameters.yml:



mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_port: 1025
mailer_user: null
mailer_password: null


config.yml:



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


But the result was the same result.










share|improve this question
























  • problem solved, a problem with the cache
    – petekaner
    Mar 17 '17 at 9:35










  • Could you explain more what the problem with the cache was? I'm facing the same issue and flushing the cache doesn't seem to resolve my issue.
    – Giel Berkers
    Mar 26 at 12:28















up vote
2
down vote

favorite












In my dev enviroment I want to use mailhog to catch the emails. I've installed and configure my php.ini to sustitute the sendmail property.
If in command line i run this



php -r "mail(......);" 


the mail gets captured by mailhog. The problem is with Symfony and Swiftmailer. To make a test i created a very simple controller with this:



/**
* @return Response
*/
public function homeAction() : Response
{
mail('some@mail.com', 'tasest', 'aaaa');
$message = Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send@example.com')
->setTo('recipient@example.com')
->setBody(
'aaaaa',
'text/html'
);
$this->get('mailer')->send($message);
return $this->render('::base.html.twig');
}


Now, the email sent by the mail function gets captured by mailhog. But not the mail sent by SwiftMailer.



In my config_dev I have this:



    # Swiftmailer Configuration
swiftmailer:
transport: "sendmail"


which I think should be enough.



Am I missing something here?



P.S.: If i use a real address (instead of recipient@example.com) the email gets sent and received



Update:
I also tried to configure mailhog for smtp, parameters.yml:



mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_port: 1025
mailer_user: null
mailer_password: null


config.yml:



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


But the result was the same result.










share|improve this question
























  • problem solved, a problem with the cache
    – petekaner
    Mar 17 '17 at 9:35










  • Could you explain more what the problem with the cache was? I'm facing the same issue and flushing the cache doesn't seem to resolve my issue.
    – Giel Berkers
    Mar 26 at 12:28













up vote
2
down vote

favorite









up vote
2
down vote

favorite











In my dev enviroment I want to use mailhog to catch the emails. I've installed and configure my php.ini to sustitute the sendmail property.
If in command line i run this



php -r "mail(......);" 


the mail gets captured by mailhog. The problem is with Symfony and Swiftmailer. To make a test i created a very simple controller with this:



/**
* @return Response
*/
public function homeAction() : Response
{
mail('some@mail.com', 'tasest', 'aaaa');
$message = Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send@example.com')
->setTo('recipient@example.com')
->setBody(
'aaaaa',
'text/html'
);
$this->get('mailer')->send($message);
return $this->render('::base.html.twig');
}


Now, the email sent by the mail function gets captured by mailhog. But not the mail sent by SwiftMailer.



In my config_dev I have this:



    # Swiftmailer Configuration
swiftmailer:
transport: "sendmail"


which I think should be enough.



Am I missing something here?



P.S.: If i use a real address (instead of recipient@example.com) the email gets sent and received



Update:
I also tried to configure mailhog for smtp, parameters.yml:



mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_port: 1025
mailer_user: null
mailer_password: null


config.yml:



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


But the result was the same result.










share|improve this question















In my dev enviroment I want to use mailhog to catch the emails. I've installed and configure my php.ini to sustitute the sendmail property.
If in command line i run this



php -r "mail(......);" 


the mail gets captured by mailhog. The problem is with Symfony and Swiftmailer. To make a test i created a very simple controller with this:



/**
* @return Response
*/
public function homeAction() : Response
{
mail('some@mail.com', 'tasest', 'aaaa');
$message = Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send@example.com')
->setTo('recipient@example.com')
->setBody(
'aaaaa',
'text/html'
);
$this->get('mailer')->send($message);
return $this->render('::base.html.twig');
}


Now, the email sent by the mail function gets captured by mailhog. But not the mail sent by SwiftMailer.



In my config_dev I have this:



    # Swiftmailer Configuration
swiftmailer:
transport: "sendmail"


which I think should be enough.



Am I missing something here?



P.S.: If i use a real address (instead of recipient@example.com) the email gets sent and received



Update:
I also tried to configure mailhog for smtp, parameters.yml:



mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_port: 1025
mailer_user: null
mailer_password: null


config.yml:



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


But the result was the same result.







php symfony email development-environment






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 17 '17 at 9:04

























asked Mar 16 '17 at 16:54









petekaner

70311126




70311126












  • problem solved, a problem with the cache
    – petekaner
    Mar 17 '17 at 9:35










  • Could you explain more what the problem with the cache was? I'm facing the same issue and flushing the cache doesn't seem to resolve my issue.
    – Giel Berkers
    Mar 26 at 12:28


















  • problem solved, a problem with the cache
    – petekaner
    Mar 17 '17 at 9:35










  • Could you explain more what the problem with the cache was? I'm facing the same issue and flushing the cache doesn't seem to resolve my issue.
    – Giel Berkers
    Mar 26 at 12:28
















problem solved, a problem with the cache
– petekaner
Mar 17 '17 at 9:35




problem solved, a problem with the cache
– petekaner
Mar 17 '17 at 9:35












Could you explain more what the problem with the cache was? I'm facing the same issue and flushing the cache doesn't seem to resolve my issue.
– Giel Berkers
Mar 26 at 12:28




Could you explain more what the problem with the cache was? I'm facing the same issue and flushing the cache doesn't seem to resolve my issue.
– Giel Berkers
Mar 26 at 12:28












2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










Swiftmailer setup in Symfony will usually have a more complete configuration, particularly in config_dev.yml, to be explicit of where you would send it.



swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
port: "%mailer_port%"
username: "%mailer_user%"
password: "%mailer_password%"


Here, if Mailhog was on port 1025 (very typical), then parameters.yml in a development environment would be set like this, to fill in the parameters in the .yml file:



mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_port: 1025
mailer_user: null
mailer_password: null





share|improve this answer



















  • 1




    tried that as well, but same result
    – petekaner
    Mar 17 '17 at 9:04


















up vote
0
down vote













I have the same problem with Symfony 4.
If you delete the variable url: '%env(MAILER_URL)%' in config/packages/swiftmailer.yaml, it should work.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42840248%2fsymfony-3-and-mailhog-mails-not-being-cached-by-mailhog%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    Swiftmailer setup in Symfony will usually have a more complete configuration, particularly in config_dev.yml, to be explicit of where you would send it.



    swiftmailer:
    transport: "%mailer_transport%"
    host: "%mailer_host%"
    port: "%mailer_port%"
    username: "%mailer_user%"
    password: "%mailer_password%"


    Here, if Mailhog was on port 1025 (very typical), then parameters.yml in a development environment would be set like this, to fill in the parameters in the .yml file:



    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_port: 1025
    mailer_user: null
    mailer_password: null





    share|improve this answer



















    • 1




      tried that as well, but same result
      – petekaner
      Mar 17 '17 at 9:04















    up vote
    2
    down vote



    accepted










    Swiftmailer setup in Symfony will usually have a more complete configuration, particularly in config_dev.yml, to be explicit of where you would send it.



    swiftmailer:
    transport: "%mailer_transport%"
    host: "%mailer_host%"
    port: "%mailer_port%"
    username: "%mailer_user%"
    password: "%mailer_password%"


    Here, if Mailhog was on port 1025 (very typical), then parameters.yml in a development environment would be set like this, to fill in the parameters in the .yml file:



    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_port: 1025
    mailer_user: null
    mailer_password: null





    share|improve this answer



















    • 1




      tried that as well, but same result
      – petekaner
      Mar 17 '17 at 9:04













    up vote
    2
    down vote



    accepted







    up vote
    2
    down vote



    accepted






    Swiftmailer setup in Symfony will usually have a more complete configuration, particularly in config_dev.yml, to be explicit of where you would send it.



    swiftmailer:
    transport: "%mailer_transport%"
    host: "%mailer_host%"
    port: "%mailer_port%"
    username: "%mailer_user%"
    password: "%mailer_password%"


    Here, if Mailhog was on port 1025 (very typical), then parameters.yml in a development environment would be set like this, to fill in the parameters in the .yml file:



    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_port: 1025
    mailer_user: null
    mailer_password: null





    share|improve this answer














    Swiftmailer setup in Symfony will usually have a more complete configuration, particularly in config_dev.yml, to be explicit of where you would send it.



    swiftmailer:
    transport: "%mailer_transport%"
    host: "%mailer_host%"
    port: "%mailer_port%"
    username: "%mailer_user%"
    password: "%mailer_password%"


    Here, if Mailhog was on port 1025 (very typical), then parameters.yml in a development environment would be set like this, to fill in the parameters in the .yml file:



    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_port: 1025
    mailer_user: null
    mailer_password: null






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 16 '17 at 19:54

























    answered Mar 16 '17 at 19:12









    Alister Bulman

    25.1k55599




    25.1k55599








    • 1




      tried that as well, but same result
      – petekaner
      Mar 17 '17 at 9:04














    • 1




      tried that as well, but same result
      – petekaner
      Mar 17 '17 at 9:04








    1




    1




    tried that as well, but same result
    – petekaner
    Mar 17 '17 at 9:04




    tried that as well, but same result
    – petekaner
    Mar 17 '17 at 9:04












    up vote
    0
    down vote













    I have the same problem with Symfony 4.
    If you delete the variable url: '%env(MAILER_URL)%' in config/packages/swiftmailer.yaml, it should work.






    share|improve this answer

























      up vote
      0
      down vote













      I have the same problem with Symfony 4.
      If you delete the variable url: '%env(MAILER_URL)%' in config/packages/swiftmailer.yaml, it should work.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        I have the same problem with Symfony 4.
        If you delete the variable url: '%env(MAILER_URL)%' in config/packages/swiftmailer.yaml, it should work.






        share|improve this answer












        I have the same problem with Symfony 4.
        If you delete the variable url: '%env(MAILER_URL)%' in config/packages/swiftmailer.yaml, it should work.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 15 hours ago









        oussaka

        591610




        591610






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42840248%2fsymfony-3-and-mailhog-mails-not-being-cached-by-mailhog%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Futebolista

            Lallio

            Jornalista