Open DevCEDTeam opened 1 year ago
To send email messages through the Gmail API, Mautic integrates with the Gmail API using the following steps:
Enable Gmail API: In the Google Cloud Console, you need to enable the Gmail API for your project. This step was covered in the previous instructions.
Obtain OAuth 2.0 Credentials: Mautic needs OAuth 2.0 credentials to access the Gmail API on behalf of the user. Follow these steps to obtain the credentials:
a. Go to the Google Cloud Console and navigate to the "APIs & Services" > "Credentials" section.
b. Click on "Create Credentials" and select "OAuth client ID".
c. Select the application type as "Web application".
d. Provide a name for the OAuth client ID and specify the authorized JavaScript origins and redirect URIs. These should match the URLs of your Mautic installation.
e. Click "Create" to generate the OAuth client ID and client secret.
f. Make note of the client ID and client secret as you'll need them later.
Configure Mautic SMTP Settings: In Mautic's configuration, you need to set up the outbound SMTP settings to connect with the Gmail API. Follow these steps:
a. Log in to your Mautic instance as an administrator.
b. Navigate to the "Configuration" menu and select "Email Settings".
c. Configure the SMTP settings with the following values:
smtp.gmail.com
587
TLS
Login
Grant Access to Gmail API: Mautic needs access to the Gmail API on behalf of the user. Follow these steps to authorize Mautic:
a. In your Mautic instance, navigate to the "Configuration" menu and select "Plugins".
b. Find the "Email Settings" plugin and click on the "Gmail API" tab.
c. Click on the "Authorize Gmail Account" button.
d. You will be redirected to the Google OAuth consent screen. Select the Gmail account you want to authorize.
e. Grant the necessary permissions requested by Mautic to access the Gmail API.
f. Once authorized, you will be redirected back to Mautic.
With these steps, Mautic is now configured to send email messages through the Gmail API. When Mautic triggers the email sending process, it uses the configured SMTP settings and the authorized Gmail API access to send emails on behalf of the user.
Mautic to GMail Integration
Step-by-step instructions that include gcloud CLI commands and sample code for installing, building, and deploying Mautic on a hosted container, configuring outbound SMTP settings, and using Cron jobs to send email messages through the Gmail API on Google Cloud using Cloud Functions for Firebase with Visual Studio Code as the code editor:
Step 1: Set up Google Cloud project and gcloud CLI
Step 2: Enable necessary APIs and services
Step 3: Set up Mautic on a hosted container
Create a Dockerfile in the project directory with the following content:
cron-jobs
file in the project directory with the following content:Step 4: Configure outbound SMTP settings on a hosted container
Step 5: Set up a Node.js project
Step 6: Create a Cloud Function for sending emails
Create a file named
index.js
in the project directory with the following content:gmail-credentials.json
in the project directory and populate it with your Gmail API credentials. Make sure to replace the placeholder values with your actual credentials:Step 7: Deploy the Cloud Function
Step 8: Set up a Cloud Scheduler job
* * * * *
for every minute).email-trigger
.That's it! You have now installed, built, and deployed Mautic on a hosted container, configured outbound SMTP settings, and set up Cron jobs to send email messages through the Gmail API on Google Cloud using Cloud Functions for Firebase.