user1752065
user1752065

Reputation: 179

How to track the email delivery status like delivered, Opened,Clicked ,Bounced,Blocked for an email sent with GMAIL API in PHP

How to track the email status like delivered, Opened,Clicked ,Bounced,Blocked for an email sent with GMAIL API. Previously we have used SendGrid for sending the email and tracking the emails. In sendgrid we have used a callback URL for tracking the emails.

Now we have switched to Gmail API for the mail sending functionality. The Email Log Search functionality in Google admin console is the tool used by the admin to track the emails. Do the google provide any API to track the emails programmatically?

PHP Code For Gmail API call

        $this->load->library('Google');
        $this->google->setScopes(["https://mail.google.com/",
        "https://www.googleapis.com/auth/gmail.compose",
        "https://www.googleapis.com/auth/gmail.modify",
        "https://www.googleapis.com/auth/gmail.send"]);
        $this->google->useApplicationDefaultCredentials();
        $this->google->setSubject($user);
        $this->google->setApplicationName("Quickstart");
        $service = new Google_Service_Gmail( $this->google); 
        // Main Process
        
        $msg = $this->createMessage($sender, $to, $subject, $messageText);
        $res = $this->sendMessage($service, $sender, $msg);

We could read the email by $service->users_messages->get method in PHP SDK. But we couldn't track the email status like Opened,Clicked ,Bounced,Blocked.

Upvotes: 1

Views: 1157

Answers (1)

zdev
zdev

Reputation: 11

The Google Workspace Email Audit API allows Google Workspace administrators to audit a user's email, email drafts, and archived chats.

Reference :- https://developers.google.com/admin-sdk/email-audit/

I believe that google didn't provided any specific API for tacking the emails.

Stack-overflow Reference :- Google Email Log Search API

Upvotes: 1

Related Questions