gmail-api

How to call Gmail API using PHP and cURL?

佐手、 提交于 2019-12-01 13:49:17
I have the oauth access token but my get request fails. Below is my code: $response = array(); $crl = curl_init(); $newurl = "https://www.googleapis.com/gmail/v1/users/myemail@gmail.com/messages?access_token=" . $result['access_token']; echo $newurl . "</br>"; curl_setopt($crl, CURLOPT_HTTPGET, true); curl_setopt($crl, CURLOPT_URL, $newurl); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); $reply = curl_exec($crl); if ( $reply ) { echo 'successfully retrieved messages</br>'; echo $reply; } else { echo 'failed to get messages</br>'; // prints echo $reply; // prints nothing } I confirmed that my

send email using gmail-api and google-api-php-client

北慕城南 提交于 2019-12-01 12:47:04
I am using https://github.com/google/google-api-php-client and I want to send a test email with a user's authorized gmail account. This is what I have so far: $msg = new Google_Service_Gmail_Message(); $msg->setRaw('gp1'); $service->users_messages->send('me', $msg); This results in a bounce email because I have no clue how to set the raw message. I see the bounce in the inbox of my authenticated user. I want to learn how to set values for 'To', 'Cc', 'Bcc', 'Subject', and 'Body' of the email. I believe I will need to do a 64 encoding on that raw data as well. And I might want to use some html

gmail with table in message body is not getting displayed in mail but table data is displayed

喜欢而已 提交于 2019-12-01 12:26:51
问题 This is my actual output This is my expected output when a mail is sent with html table along with file attachment(like image, pdf, etc.), table format is not displayed in mail but content of table is displayed. But when I inspect mail body table is present. Problem is that its not shown in table format. But when mail sent with html table without attachment, table format is getting displayed in mail. How to fix it. let user = await db.model('User').findOne({ _id: userId }); let filepath = fs

Gmail API PHP Client Library - How do you send large attachments using the PHP client library?

那年仲夏 提交于 2019-12-01 12:16:26
I'm using Google's PHP client library to send calls to Gmail's API. Using those resources, I can send messages with attachments using code like this: public function send_message(Google_Service_Gmail $gmail, $raw_message) { Log::info('Gmail API request \'users_messages->send\''); $postBody = new Google_Service_Gmail_Message(); $postBody->setRaw(Str::base64_encode_url($raw_message)); return $gmail->users_messages->send('me', $postBody, ['uploadType' => 'multipart']); } But I can't for the life of me figure out how send attachments larger than a few MB. I've found that it is necessary to use

node.js Gmail API: Getting Inline/Embedded images

匆匆过客 提交于 2019-12-01 11:00:09
问题 When grabbing an email I run the gmail.users.messages.get() and then run the following two functions to process the payload . function getBody(message) { var encodedBody = ''; try{ if(typeof message.parts === 'undefined'){ encodedBody = message.body.data; } else{ encodedBody = getHTMLPart(message.parts); } encodedBody = encodedBody.replace(/-/g, '+').replace(/_/g, '/').replace(/\s/g, ''); } catch(e) {} // there was a failure return decodeURIComponent(escape(window.atob(encodedBody))); }

How to check for incoming new messages using Gmail API

大兔子大兔子 提交于 2019-12-01 10:38:18
问题 I have set up a python script that can pull data from Gmail account, but I would like to set it up in a way that it would only pull new message since the last time I made the API call (I will be pinging the server regularly). I have looked at Push notification and Pub/Sub, but I am not quite sure if these are relevant or I should be looking at something else. Gmail also has Users.history: list function, but I am wondering if this can be used in any useful way. 回答1: You could list messages as

send email using gmail-api and google-api-php-client

感情迁移 提交于 2019-12-01 10:03:37
问题 I am using https://github.com/google/google-api-php-client and I want to send a test email with a user's authorized gmail account. This is what I have so far: $msg = new Google_Service_Gmail_Message(); $msg->setRaw('gp1'); $service->users_messages->send('me', $msg); This results in a bounce email because I have no clue how to set the raw message. I see the bounce in the inbox of my authenticated user. I want to learn how to set values for 'To', 'Cc', 'Bcc', 'Subject', and 'Body' of the email.

Sending EMail from my Javascript App via GMail API - mail appears in GMail sent list, but isn't delivered to destination email address

拜拜、爱过 提交于 2019-12-01 09:27:05
I've been writing a client (Chrome browser) App that integrates with GMail via the REST API. My app is written in Javascript/Angular and most of the GMail integration works fine. It can fetch from GMail - emails, profiles, labels, etc. I'm not able to send emails I create. However, the emails I try to send do appear in the GMail sent list and, if I modify the email by adding the 'INBOX' label, they also appear in the GMail inbox. But none of the emails make it to their destination. I've been testing with several email accounts - Hotmail, Yahoo and another GMail account. Emails are never

Creating a Gmail Draft with Recipients through Gmail API

孤人 提交于 2019-12-01 08:29:16
问题 I have been trying to figure out how to automatically add recipients to a Draft email that is created using the Gmail API through their Ruby library. I can create the draft without any issues but setting the recipients is causing me troubles and I haven't been able to find any good examples showing the best way to add email specific things. Using the Google API playground and pulling in drafts that have already been created, it looks like the structure should be something similar to what is

Sending email multipart/signed (RFC 3156) via Gmail APIs

早过忘川 提交于 2019-12-01 08:27:51
Try to build a Message in compliance with RFC3156 [0], and send it via Gmail APIs (I'm using the python client implementation). What I get is: in my Gmail box, the message is correctly sent (I see exactly the message I built before)· What my receivers get is: a "multipart/mixed" message with the same payload of the message I sent. It seems, at some point, Gmail changes my Content-Type ... is this true? As workaround, I'm using a SMTP connection (which acts like I expect, sends the message correctly), but in the future I would like to avoid this step in favor of a pure Gmail APIs application.