Help needed with: imap_fetchbody

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.

Compétences : PHP

en voir plus : content writers needed freelance writers of all backgrounds to write short articles for media, invalid method http verb used attempt access, check stock levels access, constant contact design needed help, website seo project needed help wanted, free logo needed help graphics, javascript form validation mysql username check used, salesforce help needed, virtuemart help needed, stats help tutor needed, drupal help needed, programmers help needed, check time log access 2003, visual start help needed, photography portfolio help needed, marketing help needed, python projects help needed, getafreelancer message sql query help needed, excel project help needed

Concernant l'employeur :
( 87 commentaires ) Sofia, Bulgaria

Nº du projet : #12708319

6 freelance font une offre moyenne de $23 pour ce travail


Hi, PHP, HTML, SQL,CSS,Wordpress, Opencart, Magento, Prestashop,expert with over 5 years of experience. Can work and complete the task as specified. Understood the requirement. Ready to Start. Thanks Please visit my d Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(43 Commentaires)

I have already resolve this same type can check my profile...we can discuss more over [login to view URL]

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(36 Commentaires)
%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(20 Commentaires)

Hi there! Did go through your Job Description and glad to share that I have experience in working with wordpress platform. I have more than four years of industry experience and have been the part of diverse industr Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(21 Commentaires)

why dont use oop ? .................................................................................

%bids___i_sum_sub_35% %project_currencyDetails_sign_sub_36% USD en 2 jours
(0 Commentaires)

Hi! You are right, the encoding can differ from one email to another. Therefore, you must first fetch the structure of the email and then parse the email accordingly. I can provide you with an php script which do Plus

%bids___i_sum_sub_32% %project_currencyDetails_sign_sub_33% USD en 1 jour
(0 Commentaires)