How do I send email on heroku using PHP?

前端 未结 2 945
伪装坚强ぢ
伪装坚强ぢ 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.

提交回复
热议问题