1

I have a symfony app runing on a Debian 7 VM. I'm trying to send mails using swiftMailer. All seems to be fine when running the code but no email is received. What am I missing?

Controller :

$message = \Swift_Message::newInstance()
        ->setSubject('Hello Email')
        ->setFrom('send@example.com')
        ->setTo('name.lastname@gmail.com')
        ->setBody('hello');


$mailer = $this->get('mailer');

if (!$mailer->send($message, $failures)) {
    echo "Failures:";
    print_r($failures);
    return "ko";
} else {
    return 'email sent successfully';
}

This is always returning "email sent successfully".

config.yml :

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

parameters.yml :

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

php.ini :

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = 127.0.0.1
; http://php.net/smtp-port
smtp_port = 25
TrtG
  • 2,778
  • 6
  • 26
  • 39

2 Answers2

0

Always think about logs if you don't know what is happening, you can use the logging option to true, to get some feedback, hopefully you get more informations about the issue http://symfony.com/doc/master/reference/configuration/swiftmailer.html#logging

Nawfal Serrar
  • 2,213
  • 1
  • 14
  • 22
0

In order to send emails you have to setup a mail server like postfix.

You can also check the following thread about sending emails from localhost:

How to send email from localhost using PHP on Linux

Community
  • 1
  • 1
c0nstantx
  • 39
  • 1
  • 3