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.
php symfony email development-environment
add a comment |
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.
php symfony email development-environment
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
add a comment |
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.
php symfony email development-environment
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
php symfony email development-environment
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
add a comment |
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
add a comment |
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
1
tried that as well, but same result
– petekaner
Mar 17 '17 at 9:04
add a comment |
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.
add a comment |
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
1
tried that as well, but same result
– petekaner
Mar 17 '17 at 9:04
add a comment |
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
1
tried that as well, but same result
– petekaner
Mar 17 '17 at 9:04
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered 15 hours ago
oussaka
591610
591610
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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