开发者

Using PHP to format an email?

I know it is possible to send html enabled emails. Is it also possible to send PHP enabled emails?

For this to count:

  • php code has to be sent as plain text
  • php code has to be executed on some server X only after开发者_运维问答 recipient opens the email
  • Server X is not the recipient's machine

If this is possible, what are the consequential security issues that this brings up?


You are basically trying to force the remote email client to display a remote HTML page (generated by PHP). No clients will do that, because it's a big security risk.

You could use AJAX, but all modern email clients will completely block any Javascript in the emails by default.

You can however request remote images. You could generate them on the fly (handle the jpg extension by PHP and generate the image on the fly), but that's very likely to kill your emails as spam by any spam filter. Most email clients will block remote images by default, but will usually show a button to unblock them (this does not happen for javascript scripts).


I think your best bet is sending HTML with an iFrame or you can try an Ajax call to get the HTML you want to inject (using javascript). I don't think you can just send PHP code embedded in the HTML.

Check example #4 http://php.net/manual/en/function.mail.php


This cannot be done in the way I think you are thinking. You cannot send PHP code and expect it to be interpreted by the email client.

However, you can link to an image, on your server, in the HTML email. And this image could be a PHP script which runs on your server. But most email clients do not display images by default for this very reason.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜