Sending html email having JQuery scripts

前端 未结 5 1646
醉话见心
醉话见心 2021-01-12 07:48

I\'m using PHP to send html emails. I\'ve tried to import css files inside the email, and it works fine.



        
相关标签:
5条回答
  • 2021-01-12 08:26

    Most email clients either disable email JavaScript entirely, or only allow a subset of it, due to security reasons. Web-based clients such as Gmail are likely to fall into the former category.

    You can try embedding the script file itself directly into the email, but overall using JS in emails is a bad idea that's best avoided.

    edit

    Remember, email is a static content-delivery mechanism. As another commentator noted, if you want to send someone dynamic content, email them a link to your DHTML webpage.

    0 讨论(0)
  • 2021-01-12 08:26

    Using Javascript in emails would be a security problem. And something not desirable. If you want send some fancy page to the user, why not send him the link to a page?

    0 讨论(0)
  • 2021-01-12 08:43

    @Karim79, I'm not convinced that the answer is so clear cut as you suggest.

    It all depends on the environment used to read the email, and whether that environemnt supports javascript or not. Admittedly, I suspect that most email readers would be averse to supporting javascript, in order to avoid viruses and malware, but there is no absolute reason why this couldn't be done.

    Having said that, the unpredictable level of support offered by readers would probably mean that you shouldn't rely on the script running correctly (if at all), so you'd probably want to take a 'graceful degradation' approach.

    0 讨论(0)
  • 2021-01-12 08:46

    If I recall you can only use in-line.

    BUT most email clients (especially web based) will genearlly not allow JS of any sorts.

    I have been advising and creating html newlstters etc for people for years now and general rule - don't use JS.

    A good guide for html emails is: http://www.anandgraves.com/html-email-guide#javascript

    0 讨论(0)
  • 2021-01-12 08:49

    I would never consider using JavaScript in an email, most likely the majority of your users' email clients wouldn't support it anyway so it's not worth the effor or that an overzealous e-mail filter might reject your messages.

    0 讨论(0)
提交回复
热议问题