Jump to content

Need help with email reading


everisk

Recommended Posts

I'm trying to write a simple PHP code that read emails from an account. The problem is now with the non-English subject. I work with Thai language which uses 'windows-874' character encoding. When I fetch the email headers, the subject line is gibberish.

 

Example

Email from XXXXXXXXXXXX , subject =?windows-874?B?zejSueHF6cc6IEhTQkMgQ29tbWVudHM=?=, date Wed, 12 Dec 2007 10:53:22 +0700

 

Email from XXXXXXXXX , subject Another Dec E-newsletter, date Wed, 12 Dec 2007 10:58:09 +0700

 

 

How do I get the subject line to show correctly?

Any help will be greatly appreciated. Below is my code.

 

<?php

$login="[email protected]"; //pop3 login
$password="somepassword"; //pop3 password

$conn = @imap_open("{mail.mydomain.com:110/pop3/notls}INBOX", $login, $password) or die(imap_errors());
$headers = @imap_headers($conn)
or die("Couldn't get emails");
//$numEmails = 50;
$numEmails = sizeof($headers);

for($i = 20; $i < $numEmails+1; $i++)

{

$mailHeader = @imap_headerinfo($conn, $i);
//$head = imap_fetchheader($conn, $i);

//print $head;


$from = $mailHeader->fromaddress;

$subject = strip_tags($mailHeader->subject);

$date = $mailHeader->date;

echo "<strong>$i. Email from $from, subject $subject, date $date</strong><br><br>";

}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/81354-need-help-with-email-reading/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.