Reputation: 71
I'm using Gmail API https://developers.google.com/gmail/api/v1/reference/ .
But I can't find single message info like- FROM, TO, CC, BCC, REPLY-TO with name and address. Need output as-
$msg['fromAddress'] = '[email protected]';
$msg['fromName'] = 'From Name';
$msg['to'] = array('John Lok' => '[email protected]', 'Smither Fan'=>'[email protected]');
$msg['cc'] = array('krish Hosa' => '[email protected]', 'Singam Hat'=>'[email protected]');
$msg['bcc'] = array('Loban' => '[email protected]', 'Krain Root'=>'[email protected]');
$msg['body'] = 'sample Message Text';
$msg['attachments'] = array('Flower.jpg' => 'https://filelink.com/files/Flower-d9edkifsk3edmfsdf94rffjofs.jpg', 'Bill List.pdf'=>'https://filelink.com/files/Bill-List-34324234mfskfsofsc.pdf');
$msg['reply-to'] = array('From Name' => '[email protected]');
Upvotes: 0
Views: 1113
Reputation: 2598
Gmail API requires that those mail headers fulfills the requirements of RFC2822. Then, all those headers should be compiled in a URL-safe string as defined in RFC4648. Here you can see an example of this approach to send mails.
I understand that you need to read those headers from existing mails. If that is correct, then you only have to reverse the former approach. First you would need to use users.messages.get()
to read an instance of the existing mail. In the raw
field it is stored in the previously mentioned URL-safe string. Please, ask me any further doubts.
Upvotes: 3