Question

Can I Use An External SMTP Service To Send Emails From My PHP Application From My Domain Name?

Posted November 27, 2020 443 views
PHPEmail

I setup Postfix on my server which also runs my associated website. After sending a test email I received a message stating the server was associated with spam and blocked from sending to gmail. I cannot afford a dedicated server at this stage of my development but I need a method to send emails for forgotten passwords, 2FA and occasional newsletters and they need to come from my domain name. Can I do this from PHP using Google’s SMTP server and my domain name? I’m not finding good documentation on that process.

Thanks!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi @FringeAvenue,

Yes, you can do that. You can configure your PHP to use SMTP from another server and send e-mails from it, for instance, Google. There are two basic ways of sending emails with PHP: a built-in mail function and external mail packages.

PHP’s built-in mail function () is very simple, but it provides limited functionality for sending emails. You won’t be able to add attachments to your email, and building a beautiful HTML template with embedded images will be a tricky task as well.

The other side of the PHP mail function () is that the email is sent from your web server, which may cause issues with deliverability due to security concerns such as suspicion of spam and blacklisting. The best way to overcome this problem is sending messages via an SMTP server, however, this functionality is limited as well. You can configure SMTP with some external packages, I recommend you to give the following article a read - PHP With SMTP

Regards,
KFSys

Submit an Answer