doudeng2016 2014-12-03 14:58
浏览 38
已采纳

PHP:获取阅读回执时显示实际图像

So I am working on getting an email read receipt (Laravel and PHP), where I try to update a field in DB when an email is opened.
Description
1. Send an email to a user.
2. Once that user reads the mail, update the message status from "unread" to "read" in the database.

Code I have already added to make it happen
1. Send message id to mail body.
2. Add <img> tag like,

<p><img src="http://www.xyzdomain.com/messagestatus/{{$id}}"></p>

3. Have a function in controller with route for above url, which will do the DB update for me.

Problem
Though the status is successfully updated to "Read" when a user reads that mail. The image shown in mail body is broken because i am passing a url and not image. Can someone guide me about how can I show some image like some transparent background image which won't show a broken image.
Thanks in advance.

  • 写回答

2条回答 默认 最新

  • douzepao0281 2014-12-03 15:01
    关注

    You should redirect to an image file after the DB update.. for example, create an image in this url:

    http://www.xyzdomain.com/img.png

    (Preferably a 1x1 px transparent image)

    Then after your DB update redirect using header() to this image file.

    <?php
    
       ... some db updating code ...
    
       header('Location: http://www.xyzdomain.com/img.png');
       die();
    
     ?>
    

    This way, the image will not be broken in your client's email. It will actually get an image file after updating the database.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址