skip to Main Content
  • i tried to send email through swiftmailer

  • response code 200 ok but still no email recived.

controller code

 public function EmaiAction(Request $request)
 {
    $mailer = $this->get('mailer');

    $logger = new Swift_Plugins_Loggers_ArrayLogger();
    $mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger));


    $message = Swift_Message::newInstance()
    ->setSubject('Hello')
    ->setFrom('[email protected]')
    ->setTo('***@gmail.com')
    ->setBody('This is a test email.');

    if ($this->get('mailer')->send($message)) {
    echo '[SWIFTMAILER] sent email to ';
    } else {
    echo '[SWIFTMAILER] not sending email: ' . $mailer->dump();
    }    

die("email send");

}

output

   [SWIFTMAILER] sent email to

config.yml

swiftmailer:
disable_delivery:  true
transport: smtp
encryption: ssl
port:   465
auth_mode: login
host:      smtp.gmail.com
username:  ***@gmail.com
password:  passwrd
delivery_address: [email protected]
  • on doing echo in if/else its going in if condition that means its true.

  • so why im not recieving emails.

  • no error logs appears while sending an emails

  • im using cpanel app is production enviornment.

2

Answers


  1. disable_delivery:  true
    

    This disables mail sending for development (See Docs)

    Additionally try the swiftmailer config like this

    swiftmailer:
        transport: gmail
        username:  ***@gmail.com
        password:  passwrd
    
    Login or Signup to reply.
  2. $message = Swift_Message::newInstance()
    ->setSubject('Hello')
    ->setFrom('[email protected]')
    ->setTo('***@gmail.com')
    ->setBody('This is a test email.');
    $this->get('mailer')->send($message);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search