问题描述
这个问题类似于,除了邮件客户端。例如,如果在内置的iPhone邮件客户端上打开电子邮件,它将显示专门为iPhone格式化的邮件的版本。如果在平板电脑或桌面上打开,它将显示为完整的全尺寸版本的电子邮件。这在原理上类似于通过检测用户代理(而不是电子邮件客户端)自动加载的具有移动友好版本的网站的网站。
This question is similar to "Standard way to detect mobile browsers in a web application based on the http request" except for mail clients. For instance, if an email message is opened on the built-in iPhone mail client it will display a version of the message specially formatted for the iPhone. If opened on an tablet or desktop it will display as the complete, full-size version of the email. This is similar in principle to web sites that have mobile-friendly versions of the site that load automatically by detecting the user-agent - but for email clients.
所以 - 是可以检测用于打开电子邮件的邮件客户端并相应地格式化邮件?也许是一种检测屏幕分辨率的方法?
So - is it possible to detect the mail client being used to open an email and format the message accordingly? Perhaps a way to detect the screen resolution?
推荐答案
您可以尝试应用 @media css查询针对特定的浏览器,如移动设备。 有一个很好的介绍,但请注意,它可能是只支持在一个充满了浏览器和设备的手中,iOS在他们身上幸运:)
You can try to apply @media css queries that target specific browsers like mobile devices. There is a good introduction on the campaignmonitor help website but be aware, it probably is only supported in a hand full of browsers and devices, iOS being on of them luckily :)
基本上,您正在定义针对特定屏幕宽度的CSS样式,以便您可以优化您的电子邮件的屏幕空间有限。
Basically you are defining css styles that target specific screen widths so that you can optimize your email for limited screen space.
@media only screen and (max-device-width: 480px) { ... }
当谈到真正的检测和显示完全不同的电子邮件时,这是真的不可能,因为你在谈论javascript这不是在电子邮件中完成的,甚至在所有电子邮件客户端的99%中甚至不会工作。但是,您可以使用@media查询方式走下去。
When talking really detection and displaying a totally different email, that's really impossible since you are talking about javascript there and that's not done in emails and probably won't even work in 99% of all email clients. But you can go a loooong way with @media queries.
这篇关于检测移动邮件客户端的标准方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!