Reputation: 3452
I am trying to implement send email function using php. It is working fine. But the problem when I open the email in inbox it has a lot of spaces in front of message. Is there any way to get rid of these spaces.
Do I need to add additional headers for this.
code:
$to = $email;
$from = "[email protected]";
$subject = "Registration confirmation";
$msg = "message goes here";
$mail = new EMAIL();
$arr = $mail->sendEmail($to,$from,$subject,trim($msg));
Thanks.
Upvotes: 0
Views: 640
Reputation:
Try this:
$to = $email;
$from = "[email protected]";
$subject = "Registration confirmation";
$msg = "message goes here";
$mail = new EMAIL();
$arr = $mail->sendEmail($to,$from,$subject,trim(preg_replace('/\s+/',' ', $msg));
This will remove extra spaces, as well as leading and trailing spaces.
Upvotes: 0
Reputation: 4048
Just do this:
<?php
$msg = trim($msg);
$msg = preg_replace('/\s+/', ' ', $msg);
$arr = $mail->sendEmail($to, $from, $subject, $msg);
Upvotes: 2