smarber
smarber

Reputation: 5074

send method is always returning 0

I'm using swift_mailer to handle sending emails and I'm having a problem which is emails are not sent, and the return value of the send method is always equal to zero.

app/config/config.yml

swiftmailer:
   transport: smtp
   host:      <host>  # of the company
   username:  <username> # of the company
   password:  <password> # of the company
   port: 25

app/config/config_test.yml

swiftmailer:
    disable_delivery: true
    # disable_delivery: ~ # tried with this too

Controller

$mailer = $this->get('mailer');
$message = $mailer->createMessage()
    ->setSubject('You have Completed Registration!')
    ->setFrom('[email protected]')
    ->setTo('[email protected]')
    ->setBody(
        'hello world!!',
        'text/plain'
    )

var_dump($mailer->send($message, $failed), $failed); exit;

Output:

int(0)
array(0) {
}

I know that send returns the number of persons the email has been sent to. Why the email is never sent? Given that I'm sure of the only email address I'm trying to send to.

Update1:

I'd like to know how to debug this much further.

Upvotes: 2

Views: 1140

Answers (2)

pcm
pcm

Reputation: 856

If you want to achieve a test environment mailer, do not use disable_delivery.
That completely disables swiftmailer's send.
Use

# app/config/config_dev.yml
swiftmailer:
      disable_delivery: false
      delivery_address: [email protected] # some test or development email account

Upvotes: 2

Maybe you have an error in your config. Try the logger for debug output: http://swiftmailer.org/docs/plugins.html#logger-plugin

Upvotes: 0

Related Questions