Sending email with signature using Gmail API

点点圈 提交于 2019-12-06 18:24:40

问题


I got the Gmail Rest API sending part working but the e-mail doesn't include the signature and in recipient's inbox the 'from' label is sender's user id not the name of the user.

This is in php.

    $mime = new Mail_mime();
    $mime->setFrom("ABCD");  //This doesn't work....
    $mime->setSubject('Testing');
    $mime->setTXTBody('This is a demo mail');
    $mime->addTo('a@a.com');
    $message_body = $mime->getMessage();
    $encodeMessage = base64url_encode($message_body);
    $message = new Google_Service_Gmail_Message();
    $message->setRaw($encodeMessage);
    $send = $service->users_messages->send('me', $message);

Is there anyway to include the signature and change the 'from'?


回答1:


The signature is not added by the API because it is a setting on the web client, not a global setting for the entire account. If you configure your Gmail account on Thunderbird, Outlook or another email client, Gmail will not add the signature either. You should think about Gmail in two separate ways:

  1. The web client interface, accessible at https://mail.google.com, which is just an email client like any other;
  2. Your inbox, the place where messages end up in, which is completely independent of the clients you use to access it.

In other words, this is an email client-dependent setting, and the only thing the clients do is add a bit of text to the text you write yourself, nothing else.




回答2:


I know this is old but you can retrieve via API the users signature.

https://developers.google.com/admin-sdk/email-settings/#manage_signature_settings

you can then append to your email that you are composing.



来源:https://stackoverflow.com/questions/30472079/sending-email-with-signature-using-gmail-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!