Sending mail doesn’t work anymore after deployment

So my reset-password system works perfectly fine on Localhost in both:

  • prod mode (APP_ENV=prod)
  • dev mode (APP_ENV=dev)

I deployed my Symfony4 project on Heruko and I hosted the MySQL database on db4free.com.
And I changed the DATABASE_URL on .env file like this :

DATABASE_URL=mysql://root:[email protected]:3306/smartwatchtn?serverVersion=5.7

smartwatchtn is the database name.

The login, the register everything related to the database works fine except the reset-password system!

My MAILER_DSN is Gmail:

MAILER_DSN=gmail://email:[email protected]

I keep getting a 500 error each time I request a new password, so I tried debugging with Dump() die() functions and I find out that the error comes from the send() function.
Code from ResetPasswordController.php :

    dump("1111111111");
    $email = (new TemplatedEmail())
        ->from(new Address('********@gmail.com', 'Braclet Bot'))
        ->to($user->getEmail())
        ->subject('Your password reset request')
        ->htmlTemplate('reset_password/email.html.twig')
        ->context([
            'resetToken' => $resetToken,
            'tokenLifetime' => $this->resetPasswordHelper->getTokenLifetime(),
        ])
    ;
    dump("222222");
    $mailer->send($email);
    dump("3333333333");
    die();

    $this->get('session')->getFlashBag()->add('user',$user);
    return $this->redirectToRoute('app_check_email');
}

On the page I only get this:

enter image description here

and 500 error page. So the send() function triggers the error.

Heroku logs :

2020-07-04T20:45:43.350165+00:00 app[web.1]: [0x00007f3871a13880] connect()
/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:362
2020-07-04T20:45:43.350799+00:00 app[web.1]: [0x00007f3871a137d0] connect()
/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:1449
2020-07-04T20:45:43.350800+00:00 app[web.1]: [0x00007f3871a13770] getWrappedConnection()
/app/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:892
2020-07-04T20:45:43.350905+00:00 app[web.1]: [0x00007f3871a13680] executeQuery()
/app/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php:717
2020-07-04T20:45:43.351119+00:00 app[web.1]: [0x00007f3871a13540] load()
/app/vendor/doctrine/orm/lib/Doctrine/ORM/EntityRepository.php:193
2020-07-04T20:45:43.351332+00:00 app[web.1]: [0x00007f3871a134b0] findOneBy() /app/src/Controller/ResetPasswordController.php:145
2020-07-04T20:45:43.351563+00:00 app[web.1]: [0x00007f3871a133e0] processSendingPasswordResetEmail()
/app/src/Controller/ResetPasswordController.php:47
2020-07-04T20:45:43.351771+00:00 app[web.1]: [0x00007f3871a13320] request() /app/vendor/symfony/http-kernel/HttpKernel.php:158
2020-07-04T20:45:43.351943+00:00 app[web.1]: [0x00007f3871a13240] handleRaw() /app/vendor/symfony/http-kernel/HttpKernel.php:80
2020-07-04T20:45:43.352120+00:00 app[web.1]: [0x00007f3871a13190] handle() /app/vendor/symfony/http-kernel/Kernel.php:201
2020-07-04T20:45:43.352248+00:00 app[web.1]: [0x00007f3871a130f0] handle() /app/public/index.php:25

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *