Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8742869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:34:30+00:00 2026-06-13T11:34:30+00:00

I am making a console application which uses the SwiftMail extension to send. Due

  • 0

I am making a console application which uses the SwiftMail extension to send. Due to our policy, I have two virtual machines, one which serves as a SMTP relay and the other which is the application server. Sending mail manually through telnet to the relay works fine. When using SwiftMail, it’s broken.

The headers are returned and there are no entries returned in the $failure variable for send()

Response of getHeaders()->toString()

Message-ID: <1351104631.508838778dc03@swift.generated>
Date: Wed, 24 Oct 2012 14:50:31 -0400
Subject: [YourSite] Feedback
From: noreply@localhost.com
To: sixeightzero@localhost.com
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

If I echo the send(), i get 1.

boot.php

$app->register(new Silex\Provider\SwiftmailerServiceProvider(), array(
    'swiftmailer.options' => array(
        'host' => 'ip.host.relay',
        'port' => 25,
        'encryption' => null,
        'auth_mode' => null
    ),
));

app.php

 $message = \Swift_Message::newInstance( )
        ->setSubject('[YourSite] Feedback')
        ->setFrom(array('noreply@localhost.com'))
        ->setTo(array('sixeightzero@localhost.com'))
        ->setBody("Message!");


    $app['mailer']->send($message, $failures);

When i run a TCP dump on the app server and run the script, there are no SMTP connection made, and there are no errors thrown.

Anyone encounter this before? I don’t want to use sendmail or mail, but SMTP due to our application requirements.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:34:31+00:00Added an answer on June 13, 2026 at 11:34 am

    This is because the SwiftmailerServiceProvider uses a Swift_MemorySpool by default, and only flushes that on kernel.terminate. Let me take a step back and explain each part of this.

    • The SwiftmailerServiceProvider is responsible for registering the Swiftmailer services and default configuration. By default the transport (swiftmailer.spooltransport) is Swift_SpoolTransport and the swiftmailer.spool is Swift_MemorySpool.

    • Swiftmailer supports different ways of sending the mails. These are called transports. The spool transport acts as a queue. You can either store this queue in a file or in memory. Spool transports have a flushQueue method which allows flushing the queued mails to a real transport, which should deliver them.

    • The Symfony2 HttpKernel which Silex uses emits a number of events during the lifecycle of every request. The last one that it emits is the kernel.terminate event. This event is triggered after the HTTP response body has been sent. This allows you to do heavy tasks after rendering the page, so that it no longer appears as loading to the user.

    • The SwiftmailerServiceProvider subscribes to the kernel.terminate event in order to flush the memory spool after the page has been rendered. It flushes it to swiftmailer.transport service, which is a Swift_Transport_EsmtpTransport that does the actual sending via SMTP.

    So let’s get to the actual problem. You are in a CLI context, so none of those HttpKernel events will be fired. And since the kernel.terminate event is not fired, your spool is not being flushed. And thus your emails are not getting sent.

    There’s two good solutions for this:

    • A) Flush the spool manually. Just do what the provider does in its listener. Add this at the end of your CLI command:

      if ($app['mailer.initialized']) {
          $app['swiftmailer.spooltransport']->getSpool()->flushQueue($app['swiftmailer.transport']);
      }
      
    • B) Re-configure the mailer service to use the ESMTP transport directly without going through the spool:

      $app['mailer'] = $app->share(function ($app) {
          return new \Swift_Mailer($app['swiftmailer.transport']);
      });
      

    Either solution should do. Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a console-based application in Objective-C which relies on being able to clear
I have a console application which runs hundred times a day and reads same
I'm making a Java console application that needs to send an HTTP request to
I have been using the Rails console a fair bit lately and its making
Making a word document of our network set-up. We have about 7 servers and
Hi I am making an ATM console application in C++. I am planning to
I have a console application that starts up, hosts a bunch of services (long-running
I have a console application written in C#. This application copies e mails from
Under my solution I have 2 projects Project A console application , Project B
Using a console application, I'm making use of a c++ com dll to call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.