Score:0

Send email from Heroku server using gmail account and PHPMailer

de flag
yem

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.

liske1 avatar
ye flag
Have you own site name? In example myapp.com or only mywebsite.herokuapp.com?
yem avatar
de flag
yem
Only mywebsite.herokuapp.com
Paul avatar
cn flag
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.
yem avatar
de flag
yem
i just sent a couple of test emails to a different email of mine...
Score:0
in flag

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.

yem avatar
de flag
yem
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?
t3ln3t avatar
in flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.