Closed

Help needed with: imap_fetchbody

This project received 6 bids from talented freelancers with an average bid price of $23 USD.

Get free quotes for a project like this
Project Budget
$10 - $20 USD
Total Bids
6
Project Description

I have some problems with fetching the HTML body from emails from my webserver into my MySQL database.

All the data from the email is stored correctly, it just doesn't store the HTML emails correctly.

This is the part of the PHP that has to fetch the body. I want it to fetch a plain text version and an HTML version.

-----

$message = mysqli_real_escape_string($connect,quoted_printable_decode(imap_fetchbody($inbox,$email_number,1.1)));

$message_html = mysqli_real_escape_string($connect,quoted_printable_decode(imap_fetchbody($inbox,$email_number,1.2)));

if($message == '')

{

$message = mysqli_real_escape_string($connect,strip_tags(quoted_printable_decode(imap_fetchbody($inbox,$email_number,1))));

$message_html = mysqli_real_escape_string($connect,quoted_printable_decode(imap_fetchbody($inbox,$email_number,1)));

}

-----

I checked some emails on my webserver and the encoding is not always the same:

Email 1:

Content-Type: text/plain; charset="us-ascii"

Content-Transfer-Encoding: quoted-printable

Email 2:

Content-Type: text/plain; charset="utf-8"

Content-Transfer-Encoding: base64

Content-Type: text/html; charset="utf-8"

Content-Transfer-Encoding: base64

Email 3:

Content-Type: text/html; charset=UTF-8

Content-Transfer-Encoding: quoted-printable

So, how to do it right? Should I firstly check which encoding is used?

I won't give you access to my mailserver or webserver. Of course I can supply you with the files that are relevant.

Skills Required

Looking to make some money?

  • Set your budget and the timeframe
  • Outline your proposal
  • Get paid for your work

Hire Freelancers who also bid on this project

    • Forbes
    • The New York Times
    • Time
    • Wall Street Journal
    • Times Online