PHP mail function returning wierd characters

Hi,
I am writing a email program that will send email to my registered users. here is the code.
$spaces="         ";
$sub="Account Created successfully: ".date('D dS M,Y h:i a');
$body="<html><head></head><body>";
$body.="<span style='text-align: left;text-indent: 5px;font-family: Verdana;font-size: 11px;color: #404040;'>";
$body.="<br /> $spaces Hi, <br /> Welcome to Careerglitters, <br />, You are now in one of the worlds leading job portal. <br />, We help you in getting a job easier.<br />";
$body.="<br /> $spaces Please send mail to admin@careerglitters.com for any further queries.<br />";
$body.="<br /> $spaces Please save this Email for future reference.<br />";
$body.="<br /><b>Careerglitters id:</b> $id<br /><br />";
$body.="<br /><b>Username:</b> $username<br /><br />";
$body.="<br /><b>Password:</b> $password<br /><br />";
$body.="<br /><b>Thanks,</b><br /><b>Careerglitters Recruitment group</b><br />";
$body.="</span></body></html>";
$replyto=$from;
$mailstatus.=$db->sendemail('admin@careerglitters.com', $email1, $sub, $body, $cc, $replyto);

The email that it sends is hacing some problem.
Here is the email that has been sent.

PGh0bWw+PGhlYWQ+PC9oZWFkPjxib2R5PjxzcGFuIHN0eWxlPSd0ZXh0LWFsaWduOiBsZWZ0O3Rl eHQtaW5kZW50OiA1cHg7Zm9udC1mYW1pbHk6IFZlcmRhbmE7Zm9udC1zaXplOiAxMXB4O2NvbG9y OiAjNDA0MDQwOyc+PGJyIC8+ICZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZu YnNwOyZuYnNwOyZuYnNwOyBIaSwgPGJyIC8+IFdlbGNvbWUgdG8gQ2FyZWVyZ2xpdHRlcnMsIDxi ciAvPiwgWW91IGFyZSBub3cgaW4gb25lIG9mIHRoZSB3b3JsZHMgbGVhZGluZyBqb2IgcG9ydGFs LiA8YnIgLz4sIFdlIGhlbHAgeW91IGluIGdldHRpbmcgYSBqb2IgZWFzaWVyLjxiciAvPjxiciAv PiAmbmJzcDsmbmJzcDsmbmJzcDsmbmJzcDsmbmJzcDsmbmJzcDsmbmJzcDsmbmJzcDsmbmJzcDsg UGxlYXNlIHNlbmQgbWFpbCB0byBhZG1pbkBjYXJlZXJnbGl0dGVycy5jb20gZm9yIGFueSBmdXJ0 aGVyIHF1ZXJpZXMuPGJyIC8+PGJyIC8+ICZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZu YnNwOyZuYnNwOyZuYnNwOyZuYnNwOyBQbGVhc2Ugc2F2ZSB0aGlzIEVtYWlsIGZvciBmdXR1cmUg cmVmZXJlbmNlLjxiciAvPjxiciAvPjxiPkNhcmVlcmdsaXR0ZXJzIGlkOjwvYj4gMTc8YnIgLz48 YnIgLz48YnIgLz48Yj5Vc2VybmFtZTo8L2I+IHJfbV9zaHlhbTxiciAvPjxiciAvPjxiciAvPjxi PlBhc3N3b3JkOjwvYj4gcl9tX3NoeWFtPGJyIC8+PGJyIC8+PGJyIC8+PGI+VGhhbmtzLDwvYj48 YnIgLz48Yj5DYXJlZXJnbGl0dGVycyBSZWNydWl0bWVudCBncm91cDwvYj48YnIgLz48L3NwYW4+ PC9ib2R5PjwvaHRtbD4=

Let me know why this problem is.
I am sure this is a encoding problem. But how to correct it?
Regards,G.
LVL 4
gcmachelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
It looks like the sendemail method is encrypting the data. Try the code below to see if it is sent as expected.
$spaces="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$sub="Account Created successfully: ".date('D dS M,Y h:i a');
$body="<html><head></head><body>";
$body.="<span style='text-align: left;text-indent: 5px;font-family: Verdana;font-size: 11px;color: #404040;'>";
$body.="<br /> $spaces Hi, <br /> Welcome to Careerglitters, <br />, You are now in one of the worlds leading job portal. <br />, We help you in getting a job easier.<br />";
$body.="<br /> $spaces Please send mail to admin@careerglitters.com for any further queries.<br />";
$body.="<br /> $spaces Please save this Email for future reference.<br />";
$body.="<br /><b>Careerglitters id:</b> $id<br /><br />";
$body.="<br /><b>Username:</b> $username<br /><br />";
$body.="<br /><b>Password:</b> $password<br /><br />";
$body.="<br /><b>Thanks,</b><br /><b>Careerglitters Recruitment group</b><br />";
$body.="</span></body></html>";
$replyto=$from;
//$mailstatus.=$db->sendemail('admin@careerglitters.com', $email1, $sub, $body, $cc, $replyto);
 
 
$to      = $email1;
$subject = $sub;
$message = $body;
$headers = 'From: ' . $from . "\r\n" .
    'Reply-To: ' . $replyto . "\r\n" .
    'Cc: ' . $cc;
 
if (mail($to, $subject, $message, $headers) )
	$mailstatus .= "Mail Sent OK.";
else
	$mailstatus .= "Mail Not Sent: " . $to;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gcmachelAuthor Commented:
Yes you are right. I just got that and was about to delete the question. It was the base64 encoding. If the body length is greater than 998 chars, I should use base64 encode. Now i find the solution appropriate. But your solution is also good.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.