Question

How to send email using php sendmail and google workplace smtp ?

I was having issues using php sendmail and emails getting blocked so I decided to try google workspace. I have successfully setup the email to receive but I am stuck trying to get php sendmail to send emails from my domain. I have seen tutorials on here about configuring apps for google’s smtp settings but how do I send email from my webapp so it comes from my domain ?

Also, I have two droplets one is my website xxxx.com and the other is my webapp at app.xxxx.com I need to be able to send email from both.

Any help would be greatly appreciated. Thanks, james

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

For anyone else wondering how to do this, PHP pear and Google Workspace was my answer.

alexdo
Site Moderator
Site Moderator badge
March 1, 2021

Hello, @kryptone

If you’re interested in using Postfix alongside Gmail to send emails from your droplet you can also check this mini tutorial:

https://www.digitalocean.com/community/questions/using-gmail-with-postfix-smtp-server?answer=60074

Hope that this helps! Regards, Alex

KFSys
Site Moderator
Site Moderator badge
March 1, 2021

Hi @kryptone,

I’m glad you managed to find a solution for you! Let me suggest something else as well.

Using PHP mail or PHP pear is kind of old technology. For the past years, however, everyone has been using SMTP with PHP. Sending mail via SMTP is recommended as email is sent from the mail server rather than the webserver.

I’ll recommend seeing how this works and try using it in some other projects to see if you like how it’s working.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.