最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Gmail signature not working on mailto link - Stack Overflow

programmeradmin0浏览0评论

When I use Gmail to send an email, the email signature defined in the settings is automatically added at the bottom of the email. However, when I open a mailto link to send a message, the email signature is not automatically added.

Here's the code:

<a href="mailto:[email protected]?subject=Thanks for your time&body=Hi,%0A%0AIt%20was%20a%20real%20pleasure%20speaking%20with%20you.%20Thank%20you%20for%20your%20time%20and%20we'll%20be%20in%20touch%20soon." target="_blank">test</a>

And there's a JSFiddle here. What do I need to do to make the email signature appear when I'm sending from a mailto link?

When I use Gmail to send an email, the email signature defined in the settings is automatically added at the bottom of the email. However, when I open a mailto link to send a message, the email signature is not automatically added.

Here's the code:

<a href="mailto:[email protected]?subject=Thanks for your time&body=Hi,%0A%0AIt%20was%20a%20real%20pleasure%20speaking%20with%20you.%20Thank%20you%20for%20your%20time%20and%20we'll%20be%20in%20touch%20soon." target="_blank">test</a>

And there's a JSFiddle here. What do I need to do to make the email signature appear when I'm sending from a mailto link?

Share Improve this question edited Feb 27, 2023 at 19:26 halfer 20.4k19 gold badges108 silver badges201 bronze badges asked Nov 11, 2015 at 22:15 frenchiefrenchie 51.9k117 gold badges319 silver badges526 bronze badges 5
  • @DaniSpringer: tried on both settings, tried on a Chromebook; problem persists. – frenchie Commented Nov 19, 2015 at 12:33
  • It works for me with your existing code. Is there a chance Google is seeing the chromebook as a mobile device for some weird reason? Do you have a mobile sig set up as well? – Drazisil Commented Nov 19, 2015 at 14:52
  • @DaniSpringer: can you update the fiddle with "a link"? The fiddle has an <a> tag; what do you mean with "a link? – frenchie Commented Nov 19, 2015 at 18:50
  • @Drazisil: doesn't work for me, there must be a problem somewhere. – frenchie Commented Nov 19, 2015 at 18:51
  • 1 I guess &body= sets the whole body, and unless there is a way to signal that the signature should be added (e.g. &body=etc%20etc%20{signature}) there is no way to acomplish this. – Halil Özgür Commented Dec 3, 2015 at 21:03
Add a comment  | 

3 Answers 3

Reset to default 7

Using body as a parameter in the mailto link replaces everything that is already placed into the email by Gmail. If body is not part of the attribute from mailto, then the signature works as expected.

Source: I tested this with your fiddle by removing the body attribute and clicked the link again. It works just as you want.

I have to add code to submit this answer with a fiddle, so here is the link that will work with a signature:

<a href="mailto:[email protected]?subject=Thanks for your time" target="_blank">test</a>

Do this (on desktop of course):

http://mail.google.com/mail/?view=cm&fs=1&tf=1&[email protected]&su=Hello%20Dani%20(via%20Stack%20OverFlow)">http://mail.google.com/mail/?view=cm&fs=1&tf=1&[email protected]&su=Hello%20Dani%20(via%20Stack%20OverFlow)

Note:
If you want your gmail signature, you must use gmail.
If you'd like to use a different client, you must make a signature on that client itself.

A workaround for this which could be used in conjunction with above answers:

  1. Compose new email, leave it totally blank
  2. Save the email as a canned response titled something like "SIG"
  3. When clicking a mailto link with a body description, you can go the the last line of the email and insert your SIG canned response to dump your signature in there.
发布评论

评论列表(0)

  1. 暂无评论