title: How to track the email delivery status like delivered, Opened,Clicked ,Bounced,Blocked for an email sent with GMAIL API in PHP
body: <p>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.</p>
  <p>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?</p>
  <p>PHP Code For Gmail API call</p>
  <pre><code>        $this-&gt;load-&gt;library('Google');
          $this-&gt;google-&gt;setScopes([&quot;https://mail.google.com/&quot;,
          &quot;https://www.googleapis.com/auth/gmail.compose&quot;,
          &quot;https://www.googleapis.com/auth/gmail.modify&quot;,
          &quot;https://www.googleapis.com/auth/gmail.send&quot;]);
          $this-&gt;google-&gt;useApplicationDefaultCredentials();
          $this-&gt;google-&gt;setSubject($user);
          $this-&gt;google-&gt;setApplicationName(&quot;Quickstart&quot;);
          $service = new Google_Service_Gmail( $this-&gt;google); 
          // Main Process
          
          $msg = $this-&gt;createMessage($sender, $to, $subject, $messageText);
          $res = $this-&gt;sendMessage($service, $sender, $msg);
  </code></pre>
  <p>We could read the email by <strong>$service-&gt;users_messages-&gt;get</strong> method in PHP SDK. But we couldn't track the email status like Opened,Clicked ,Bounced,Blocked.</p>