0

I have a Heroku app which has a php script that send out an email. The email sent always goes to spam.

Let's say the heroku app is mywebsite.herokuapp.com and my email is [email protected]. Based on my research I understand that the problem might be that the email is being sent from my server which is mywebsite.herokuapp.com but the email address is gmail.com.

If I used $mail->Host = 'smtp.gmail.com'; can this be the problem?

Based on my research other problems might be with the SPF or the DKIM

I spent a ton of hours trying to look it up online but everything I found had to do with custom domains and their DNS settings (for a start) which you can't have with a Heroku app.

Any suggestions?

Thanks!

This was the closest that I got to helpful information but it didn't give me enough information to go on.

4
  • Have you own site name? In example myapp.com or only mywebsite.herokuapp.com? Commented Jan 1, 2022 at 16:29
  • Only mywebsite.herokuapp.com Commented Jan 1, 2022 at 16:32
  • Depending on how much mail and what type of mail goes through Gmail, you may get your Gmail account suspended or cancelled as a violation of their ToS. Commented Jan 1, 2022 at 16:51
  • i just sent a couple of test emails to a different email of mine... Commented Jan 1, 2022 at 16:56

1 Answer 1

0

You can send mail thru gmail but getting it going is a process. You'll have to generate an app userid/pass and then do the setup steps for your system's MTA (i.e. Postfix/sendmail). I've done this myself several times and it works well. There are sending limits however, even if you have a paid gmail account (i.e. Google for Business).

The source! Google itself says to do it this way: https://support.google.com/a/answer/2956491?hl=en

and one from other users on serverfault: Configure Postfix to send/relay emails Gmail (smtp.gmail.com) via port 587

You can also use services like SendGrid and MailChimp but they'll also want money. Free gmail accounts can do this however the sending limits are much lower.

2
  • But what if I have the email proccess going, meaning the emails send but if I send it to someone this way it goes to spam automatically until the user marks it as non spam? Commented Jan 1, 2022 at 17:17
  • Using DKIM and SPF in conjunction with a commercial mail relay service should keep your mail out of user SPAM folders unless your mails get flagged for something else typical of UCE. Commented Jan 6, 2022 at 20:27

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.