When I fetch a particular mail using imap in php, I get some some encoded text before the fetched mail. How can I remove the encoded part..??
For eg.
--001a11c129bebb60d204f687b277 Content-Type: text/plain; charset=ISO-8859-1
Sir, I would like to request you to grant me the permission to use the CSE lab number 1 for the Polaris event we are organizing from 26th September to 28th September. Regards ABC -- Chinmay Joshi --001a11c129bebb60d204f687b277 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Sir, =A0=A0=A0=A0=A0=A0
I would like to request you to =
grant me the permission to use the CSE lab number 1 for the Polaris event we are organizing from 26th September to 28th S= eptember
.
Regards ABC
<?php
function hey()
{
$con=mysqli_connect("localhost","root","","project 6 sem");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM data where pkey='Permission' and skey='lab'");
while($row = mysqli_fetch_array($result))
{
echo $row['reply1_yes'] . " " . $row['reply2_yes'];
echo "<br>";
break;
}
mysqli_close($con);
return;
}
?>
<?php
$con=mysqli_connect("localhost",'root',"","project 6 sem");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
echo "Database connected..</br>";
?>
<?php
/* connect to server */
$hostname= '{imap.gmail.com:993/ssl/novalidate-cert}';
$username = 'exid@gmail.com';
$password = 'fktgi';
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Tiriyo: ' . imap_last_error());
/* grab emails */
$emails = imap_search($inbox,'ALL');
$count = imap_num_msg($inbox);
if($inbox)
{
//Check no.of.msgs
$num = imap_num_msg($inbox);
$emails = imap_search($inbox,'ALL');
rsort($emails);
//if there is a message in your inbox
if( $num >0 )
{
$body1=imap_body($inbox,$num);
$body=explode(" ",imap_body($inbox,$num));
$count=count($body);
echo "$body1";
//read that mail recently arrived
for($i=1;$i<$count;$i++)
{
if($body[$i]=="lab")
{
// Check connection
echo hey();
break;
}
}
}
}
//close the stream
imap_close($inbox);
?>
<?php
mysqli_close($con);
?>