How do I send email on heroku using PHP?

前端 未结 2 941
伪装坚强ぢ
伪装坚强ぢ 2021-01-12 14:21

I have created PHP app and deployed using heroku. In the app, I have contact form to send mails to my gmail account. To implement this, I have written the following PHP code

相关标签:
2条回答
  • 2021-01-12 15:02

    Its not easy to send email through smtp on heroku without an add-on.

    I'll suggest you checkout the Sendgrid Heroku Add-on Sendgrid is a Flexible Web and SMTP APIs, plus a simple SMTP Relay set-up, allow you to decide which integration method is right for your environment.

    Check it out, it should be the solution to the problem, as it solved mine.

    UPDATE

    For starters, try out sendgrid, it'll be straight forward to use. But note that Sendgrid is just one of the many options that one could use. You can send using any SMTP server of your choice, so far you have the required credentials like username, password, host, port, driver, and/or encryption.

    PHPMailer provides the functionality you'll need. So just integrate PHPMailer, or any similar package with you app, and provide the required credentials provided by your SMTP server.

    0 讨论(0)
  • 2021-01-12 15:09

    Heroku doesnt allow send e-mails, you must use external SMTP server.

    "To send emails from applications deployed to Heroku, use an external SMTP service." https://devcenter.heroku.com/articles/smtp

    How to send e-mails throw SMTP is described here: Sending email with PHP from an SMTP server

    0 讨论(0)
提交回复
热议问题