[RESOLVED] Receiving email issues
This is my code.
PHP Code:
$message = imap_fetchbody($inbox, $email_number, 1.2);
if ($message == "") {
$message = imap_fetchbody($inbox, $email_number, 1.1);
}
if ($message == "") {
$message = imap_fetchbody($inbox, $email_number, 1);
}
$FindHashes = stripos($message, "####");
$StaffMessage = (substr($message,0,$FindHashes))."</body></html>";
$StaffMessage = quoted_printable_decode($StaffMessage);
$StaffMessage = htmlspecialchars($StaffMessage, ENT_QUOTES);
Yes it may look a bit untidy, but that is not the problem. The problem I'm having is that if the email (sent from outlook '07) does not have an attachment I don't get anything but a nasty looking plain text email. If I do have an attachment on the email then I get lovely colored formatted email.
FYI I am decoding the htmlspecialchars before I display them.
How do I get a nice email if there is nothing attached?
Thanks in advance :)
Re: Receiving email issues
check the entire value of $message after it's returned from imap_fetchbody():
PHP Code:
echo '<xmp>' . $message . '</xmp>';
if you have no attachments, part 1 will contain the message body -- but make sure you're getting what you're expecting.
you might want to take a look at this comment on PHP.net, too.
Re: Receiving email issues
Do you mean using this to get the entire?
PHP Code:
imap_fetchbody($inbox, $email_number, 0)
Re: Receiving email issues
SOLVED IT!
Basically (Thanks to Kow) I discovered I was reading the wrong parts based on content, using this script I discovered the best ones to use.
PHP Code:
print "<p><h1>1</h1>".quoted_printable_decode(imap_fetchbody($inbox, $email_number, 0, FT_PEEK))."</p><hr>";
print "<p><h1>2</h1>".quoted_printable_decode(imap_fetchbody($inbox, $email_number, 1, FT_PEEK))."</p><hr>";
print "<p><h1>3</h1>".quoted_printable_decode(imap_fetchbody($inbox, $email_number, 1.1, FT_PEEK))."</p><hr>";
print "<p><h1>4</h1>".quoted_printable_decode(imap_fetchbody($inbox, $email_number, 1.2, FT_PEEK))."</p><hr>";
print "<p><h1>5</h1>".quoted_printable_decode(imap_fetchbody($inbox, $email_number, 2, FT_PEEK))."</p><hr>";