dongshao1981 2015-01-16 20:33
浏览 58
已采纳

如何将HTML / CSS输出作为附件邮寄?

I contribute to a business software suite with a backend coded in PHP. Our client has made the request that our reports as we know them -- full of charts, tables, visual flourishes -- be emailable. They will schedule a time for certain mails to go off on a per-user basis and it will run a report with the options they desire, then essentially copy what's been output and mail them.

We do something like this already, but it's a very exhaustive process to teach these reports how to go from the screen to email; floating divs are a mess, various styles broken by Outlook 2007.

I'm inquiring on how to take the output and save it as something attachable to the email. That would be their report. Presently we just print out an HTML email directly from the cron-run PHP file.

I've looked into PDF converters and they will probably not work out; we can live without charts, but a lot of our styling won't be interpreted correctly by the PDF. The ideal product is one that would "screenshot" our output and save it as a JPG, if such a thing is possible to exist. My question is basically, does anyone know how to save us tons of work for a better product by putting output into a JPG? I know it has to be rendered from the browser, it's probably a silly notion but hopefully someone can lead me in the right direction.

  • 写回答

1条回答 默认 最新

  • dongluan1743 2015-01-16 20:45
    关注

    In my personal experience, as i've done this for our platform, we generate the html as a regular page and then email it, taking care of using relative paths for images, and then using PHPMailer for sending it through a SMTP server.

    We send the reports as the main mail body, not as an attachment.

    As an additional hint, we use Javascript libraries for the charts, and as an intermediate step, render the charts as PNG via CasperJS, that way we can develop very good looking charts in Chrome/Firefox, and then render those statically for sending via email.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line