dongtu0363 2014-03-25 07:33
浏览 89
已采纳

从imap_headerinfo函数或imap_search函数中获取“To”字段值

I have following code to get the value from 'To', but the output is Array

$header=imap_headerinfo($inbox,'18');
echo $header->to;

Second I use imap_search function to search through the email & find the desired string in the email body. Now some of the email clients do use different body, so let's say for yahoo. The actual email in Outlook or any other client looks like this:

The mail system

<dkkfdjhfhjd@gmail.com>: host gmail-smtp-in.l.google.com[173.194.77.26] said:
550-5.1.1 The email account that you tried to reach does not exist. Please
try 550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at 550 5.1.1
http://support.google.com/mail/bin/answer.py?answer=6596
c10si1356788oed.181 - gsmtp (in reply to RCPT TO command)

However when I try to print it by:

$message = imap_fetchbody($inbox,'18',1);
echo $message;

It prints like this:

The mail system : host gmail-smtp-in.l.google.com[173.194.77.26] said: 550-5.1.1
The email account that you tried to reach does not exist. Please try 550-5.1.1 
double-checking the recipient's email address for typos or 550-5.1.1 unnecessary 
spaces. Learn more at 550 5.1.1 http://support.google.com/mail/bin/answer.py?
answer=6596c10si1356788oed.181 - gsmtp (in reply to RCPT TO command)

I cannot get the email address from this as well. Can anyone tell the decent method to get the email address of the users whose delivery got failed? From headers or anything else? I need it badly, can anyone help?

  • 写回答

1条回答 默认 最新

  • douduiwei2831 2014-03-25 07:55
    关注

    The array you get is an array of addresses.

    The best way to get the address that failed is to look at the bodyparts, find the one with content-type message/delivery-status, and parse that.

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

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站