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@mydomain.com"; //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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.