I have a Heroku app which has a php script that send out an email. The email sent always goes to spam. I know that this question has been asked many times before, but I haven't been able to find a solution that helped me solve the issue for a Heroku website without a custom domain while using a gmail acount.
Let's say the heroku app is mywebsite.herokuapp.com and my email is mywebsite@gmail.com. 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, but it seems like sending it through a gmail account might make this not an issue?
Server Settings:
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'mywebsite@gmail.com';
$mail->Password = 'secretpassword';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
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.
This link gave a lot of general (very helpful) information but I can't tell from this whether or not there is a solution for my situation. This was the closet that I got to helpful information but it didn't give me enough information to go on.
Any suggestions?
Thanks