I'm trying to develop a web application that send email throught Gmail API. But I'm getting this error
Fatal error: Uncaught Error: Class 'Google_Service_Gmail_Message' not found in /var/www/html/wordpress/multi_users/approval.php:18 Stack trace: #0 {main} thrown in /var/www/html/wordpress/multi_users/approval.php on line 18
approval.php
<?php
// include your composer dependencies
require_once '/../../gmail/vendor/autoload.php';
// ERRORS
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$user = 'me';
$strSubject = 'Test mail using GMail API' . date('M d, Y h:i:s A');
$strRawMessage = "From: myAddress<[email protected]>\r\n";
$strRawMessage .= "To: toAddress <[email protected]>\r\n";
$strRawMessage .= 'Subject: =?utf-8?B?' . base64_encode($strSubject) . "?=\r\n";
$strRawMessage .= "MIME-Version: 1.0\r\n";
$strRawMessage .= "Content-Type: text/html; charset=utf-8\r\n";
$strRawMessage .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n\r\n";
$strRawMessage .= "this <b>is a test message!\r\n";
// The message needs to be encoded in Base64URL
$mime = rtrim(strtr(base64_encode($strRawMessage), '+/', '-_'), '=');
$msg = new Google_Service_Gmail_Message();
$msg->setRaw($mime);
//The special value **me** can be used to indicate the authenticated user.
$service->users_messages->send("me", $msg);
I found the code above to send the email, but I'm sure it is missing some lines. The API has just been installed and should be working fine. The error comes from this line: $msg = new Google_Service_Gmail_Message();