[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

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.
0
gcmachel
Asked:
gcmachel
1 Solution
 
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
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now