samedi 28 avril 2018

Laravel use view while sending email from Gmail API

I am trying to send emails using Gmail API. It worked fine if I use raw body, but I am unable to figure out how to use Laravel Views as the body when sending the email from Gmail API . Or use Gmail API to send using Laravel Mail Here is my code:

        $strSubject = 'Test mail using GMail API';
        $strRawMessage = "To: Someone <someone@domain.com>\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 is body";
        $service = new Google_Service_Gmail($client);

        try{
            $mime = rtrim(strtr(base64_encode($strRawMessage), '+/', '-_'), '=');
            $msg = new Google_Service_Gmail_Message($client);

            $msg->setRaw($mime);
            $service->users_messages->send("me", $msg);

        }
        catch(Exception $e){
            \Log::info($e->getMessage());

        }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire