Swift Mailer on Symfony 3.4, configuration

Multi tool use
This is what I see with php bin/console debug:config swiftmailer
:
I can send emails with php bin/console swiftmailer:email:send
they are sent ok:
Here is the email in my account:
But I can't do it with my controller on Symfony. I have tested many examples, none one works. I have tested on dev and prod enviroment (here mainly, here is where I need it of course). This is an example of my code:
public function sendEmail(Request $request ) {
$message = Swift_Message::newInstance()
->setSubject('Some Subject')
->setFrom('example@gmail.com')
->setTo('myemail@gmail.com')
->setBody('asdas');
$this->get('mailer')->send($message);
dump($message);
die();
I can see the full message in the output but no email is sent.
I have tested also this way:
$message = (new Swift_Message('Wonderful Subject'))
->setFrom(['john@doe.com' => 'John Doe'])
->setTo(['myemail@gmail.com' => 'A name'])
->setBody('Here is the message itself');
$this->get('mailer')->send($message);
Same, nothing happens. What could be wrong?
php symfony swiftmailer
add a comment |
This is what I see with php bin/console debug:config swiftmailer
:
I can send emails with php bin/console swiftmailer:email:send
they are sent ok:
Here is the email in my account:
But I can't do it with my controller on Symfony. I have tested many examples, none one works. I have tested on dev and prod enviroment (here mainly, here is where I need it of course). This is an example of my code:
public function sendEmail(Request $request ) {
$message = Swift_Message::newInstance()
->setSubject('Some Subject')
->setFrom('example@gmail.com')
->setTo('myemail@gmail.com')
->setBody('asdas');
$this->get('mailer')->send($message);
dump($message);
die();
I can see the full message in the output but no email is sent.
I have tested also this way:
$message = (new Swift_Message('Wonderful Subject'))
->setFrom(['john@doe.com' => 'John Doe'])
->setTo(['myemail@gmail.com' => 'A name'])
->setBody('Here is the message itself');
$this->get('mailer')->send($message);
Same, nothing happens. What could be wrong?
php symfony swiftmailer
add a comment |
This is what I see with php bin/console debug:config swiftmailer
:
I can send emails with php bin/console swiftmailer:email:send
they are sent ok:
Here is the email in my account:
But I can't do it with my controller on Symfony. I have tested many examples, none one works. I have tested on dev and prod enviroment (here mainly, here is where I need it of course). This is an example of my code:
public function sendEmail(Request $request ) {
$message = Swift_Message::newInstance()
->setSubject('Some Subject')
->setFrom('example@gmail.com')
->setTo('myemail@gmail.com')
->setBody('asdas');
$this->get('mailer')->send($message);
dump($message);
die();
I can see the full message in the output but no email is sent.
I have tested also this way:
$message = (new Swift_Message('Wonderful Subject'))
->setFrom(['john@doe.com' => 'John Doe'])
->setTo(['myemail@gmail.com' => 'A name'])
->setBody('Here is the message itself');
$this->get('mailer')->send($message);
Same, nothing happens. What could be wrong?
php symfony swiftmailer
This is what I see with php bin/console debug:config swiftmailer
:
I can send emails with php bin/console swiftmailer:email:send
they are sent ok:
Here is the email in my account:
But I can't do it with my controller on Symfony. I have tested many examples, none one works. I have tested on dev and prod enviroment (here mainly, here is where I need it of course). This is an example of my code:
public function sendEmail(Request $request ) {
$message = Swift_Message::newInstance()
->setSubject('Some Subject')
->setFrom('example@gmail.com')
->setTo('myemail@gmail.com')
->setBody('asdas');
$this->get('mailer')->send($message);
dump($message);
die();
I can see the full message in the output but no email is sent.
I have tested also this way:
$message = (new Swift_Message('Wonderful Subject'))
->setFrom(['john@doe.com' => 'John Doe'])
->setTo(['myemail@gmail.com' => 'A name'])
->setBody('Here is the message itself');
$this->get('mailer')->send($message);
Same, nothing happens. What could be wrong?
php symfony swiftmailer
php symfony swiftmailer
asked Dec 28 '18 at 3:18


pmirnd
70421129
70421129
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You are using the spool option which delays the sending emails. Disable the spool or remove the die().
https://symfony.com/doc/current/email/spool.html
When you use Swiftmail spool it saves the email to send it during the termination event ( https://symfony.com/doc/current/components/http_kernel.html#the-kernel-terminate-event ) which in your case it is not happening as you are killing the script with die();
in your last line.
kernel.terminate in the Symfony Framework
If you use the memory spooling option of the default Symfony mailer, then the EmailSenderListener is activated, which actually delivers any emails that you scheduled to send during the request.
I tested with smtp (as transporter) from gmail and it works everything ok, with the same code on the controller, so how would affect the die() there? I can't use themail
transporter, but I need it because I don't must use external smtps for emails, even though I know thatmail
is deprecated, but I tried withsendmail
but I can't get it neither, and at least as I posted I know I can send emails withmail
– pmirnd
Dec 28 '18 at 16:06
You should not kill unexpectedly a Symfony application unless you fully understand the consequences. This is one of the cases. I really encourage you to remove the die(). Although removing the spool part of your setup will fix your issue. Please check the doc attached to the solution to understand what it is going on.
– albert
Jan 3 at 14:48
add a comment |
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',
autoActivateHeartbeat: false,
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
});
}
});
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%2f53953294%2fswift-mailer-on-symfony-3-4-configuration%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are using the spool option which delays the sending emails. Disable the spool or remove the die().
https://symfony.com/doc/current/email/spool.html
When you use Swiftmail spool it saves the email to send it during the termination event ( https://symfony.com/doc/current/components/http_kernel.html#the-kernel-terminate-event ) which in your case it is not happening as you are killing the script with die();
in your last line.
kernel.terminate in the Symfony Framework
If you use the memory spooling option of the default Symfony mailer, then the EmailSenderListener is activated, which actually delivers any emails that you scheduled to send during the request.
I tested with smtp (as transporter) from gmail and it works everything ok, with the same code on the controller, so how would affect the die() there? I can't use themail
transporter, but I need it because I don't must use external smtps for emails, even though I know thatmail
is deprecated, but I tried withsendmail
but I can't get it neither, and at least as I posted I know I can send emails withmail
– pmirnd
Dec 28 '18 at 16:06
You should not kill unexpectedly a Symfony application unless you fully understand the consequences. This is one of the cases. I really encourage you to remove the die(). Although removing the spool part of your setup will fix your issue. Please check the doc attached to the solution to understand what it is going on.
– albert
Jan 3 at 14:48
add a comment |
You are using the spool option which delays the sending emails. Disable the spool or remove the die().
https://symfony.com/doc/current/email/spool.html
When you use Swiftmail spool it saves the email to send it during the termination event ( https://symfony.com/doc/current/components/http_kernel.html#the-kernel-terminate-event ) which in your case it is not happening as you are killing the script with die();
in your last line.
kernel.terminate in the Symfony Framework
If you use the memory spooling option of the default Symfony mailer, then the EmailSenderListener is activated, which actually delivers any emails that you scheduled to send during the request.
I tested with smtp (as transporter) from gmail and it works everything ok, with the same code on the controller, so how would affect the die() there? I can't use themail
transporter, but I need it because I don't must use external smtps for emails, even though I know thatmail
is deprecated, but I tried withsendmail
but I can't get it neither, and at least as I posted I know I can send emails withmail
– pmirnd
Dec 28 '18 at 16:06
You should not kill unexpectedly a Symfony application unless you fully understand the consequences. This is one of the cases. I really encourage you to remove the die(). Although removing the spool part of your setup will fix your issue. Please check the doc attached to the solution to understand what it is going on.
– albert
Jan 3 at 14:48
add a comment |
You are using the spool option which delays the sending emails. Disable the spool or remove the die().
https://symfony.com/doc/current/email/spool.html
When you use Swiftmail spool it saves the email to send it during the termination event ( https://symfony.com/doc/current/components/http_kernel.html#the-kernel-terminate-event ) which in your case it is not happening as you are killing the script with die();
in your last line.
kernel.terminate in the Symfony Framework
If you use the memory spooling option of the default Symfony mailer, then the EmailSenderListener is activated, which actually delivers any emails that you scheduled to send during the request.
You are using the spool option which delays the sending emails. Disable the spool or remove the die().
https://symfony.com/doc/current/email/spool.html
When you use Swiftmail spool it saves the email to send it during the termination event ( https://symfony.com/doc/current/components/http_kernel.html#the-kernel-terminate-event ) which in your case it is not happening as you are killing the script with die();
in your last line.
kernel.terminate in the Symfony Framework
If you use the memory spooling option of the default Symfony mailer, then the EmailSenderListener is activated, which actually delivers any emails that you scheduled to send during the request.
answered Dec 28 '18 at 8:04
albert
2,94011131
2,94011131
I tested with smtp (as transporter) from gmail and it works everything ok, with the same code on the controller, so how would affect the die() there? I can't use themail
transporter, but I need it because I don't must use external smtps for emails, even though I know thatmail
is deprecated, but I tried withsendmail
but I can't get it neither, and at least as I posted I know I can send emails withmail
– pmirnd
Dec 28 '18 at 16:06
You should not kill unexpectedly a Symfony application unless you fully understand the consequences. This is one of the cases. I really encourage you to remove the die(). Although removing the spool part of your setup will fix your issue. Please check the doc attached to the solution to understand what it is going on.
– albert
Jan 3 at 14:48
add a comment |
I tested with smtp (as transporter) from gmail and it works everything ok, with the same code on the controller, so how would affect the die() there? I can't use themail
transporter, but I need it because I don't must use external smtps for emails, even though I know thatmail
is deprecated, but I tried withsendmail
but I can't get it neither, and at least as I posted I know I can send emails withmail
– pmirnd
Dec 28 '18 at 16:06
You should not kill unexpectedly a Symfony application unless you fully understand the consequences. This is one of the cases. I really encourage you to remove the die(). Although removing the spool part of your setup will fix your issue. Please check the doc attached to the solution to understand what it is going on.
– albert
Jan 3 at 14:48
I tested with smtp (as transporter) from gmail and it works everything ok, with the same code on the controller, so how would affect the die() there? I can't use the
mail
transporter, but I need it because I don't must use external smtps for emails, even though I know that mail
is deprecated, but I tried with sendmail
but I can't get it neither, and at least as I posted I know I can send emails with mail
– pmirnd
Dec 28 '18 at 16:06
I tested with smtp (as transporter) from gmail and it works everything ok, with the same code on the controller, so how would affect the die() there? I can't use the
mail
transporter, but I need it because I don't must use external smtps for emails, even though I know that mail
is deprecated, but I tried with sendmail
but I can't get it neither, and at least as I posted I know I can send emails with mail
– pmirnd
Dec 28 '18 at 16:06
You should not kill unexpectedly a Symfony application unless you fully understand the consequences. This is one of the cases. I really encourage you to remove the die(). Although removing the spool part of your setup will fix your issue. Please check the doc attached to the solution to understand what it is going on.
– albert
Jan 3 at 14:48
You should not kill unexpectedly a Symfony application unless you fully understand the consequences. This is one of the cases. I really encourage you to remove the die(). Although removing the spool part of your setup will fix your issue. Please check the doc attached to the solution to understand what it is going on.
– albert
Jan 3 at 14:48
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f53953294%2fswift-mailer-on-symfony-3-4-configuration%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
4TbWuLjJmKq50Q6UNjh F nR6,zzy2YG,LDP DrXuZgtM,HPb eeLrTMoI