I am sending an email with no problem, building a mime message (I used PHP_Mailer as it was already on the server and just did $mime_email = $php_mailer->GetSentMIMEMessage();
) and sending it with (works fine):
$objGMail = new Google_Service_Gmail($client);
// The message needs to be encoded in Base64URL
$mime = rtrim(strtr(base64_encode($mime_email), '+/', '-_'), '=');
// Create a message
$gmail_msg = new Google_Service_Gmail_Message();
$gmail_msg->setRaw($mime);
// Send the email
$objGMail->users_messages->send('me', $gmail_msg);
The issue is that it ignores the "From" (email sender) set in the MIME email and reverts it to the email of the $client
. All I want to do is change the from to a permitted alias email. I have found other solutions, other than changing basic settings of the account, being something I don't want to do as I only want to change the sender email for this particular email.
To simplify, email address "me@some_email.com" is the gmail account with a mailbox and "info@some_email.com" is an alias. I can set the sender as "info@some_email.com" fine using GMail SMTP servers, but I can't do it for just the email being sent using the GMail API, which is what I need to do.