如何消除电子邮件正文中的空格-php发送邮件
我正在尝试使用php实现发送电子邮件功能。它工作得很好。但问题是,当我在收件箱中打开电子邮件时,邮件前面有很多空间。有没有办法摆脱这些空间 我是否需要为此添加其他标题 代码:如何消除电子邮件正文中的空格-php发送邮件,php,Php,我正在尝试使用php实现发送电子邮件功能。它工作得很好。但问题是,当我在收件箱中打开电子邮件时,邮件前面有很多空间。有没有办法摆脱这些空间 我是否需要为此添加其他标题 代码: $to = $email; $from = "email@gmail.com"; $subject = "Registration confirmation"; $msg = "message goes here"; $mail = new EMAIL(); $arr = $mail->sendEmail($to,$
$to = $email;
$from = "email@gmail.com";
$subject = "Registration confirmation";
$msg = "message goes here";
$mail = new EMAIL();
$arr = $mail->sendEmail($to,$from,$subject,trim($msg));
$to = $email;
$from = "email@gmail.com";
$subject = "Registration confirmation";
$msg = "message goes here";
$mail = new EMAIL();
$arr = $mail->sendEmail($to,$from,$subject,trim(preg_replace('/\s+/',' ', $msg));
谢谢。只要这样做:
<?php
$msg = trim($msg);
$msg = preg_replace('/\s+/', ' ', $msg);
$arr = $mail->sendEmail($to, $from, $subject, $msg);
试试这个:
$to = $email;
$from = "email@gmail.com";
$subject = "Registration confirmation";
$msg = "message goes here";
$mail = new EMAIL();
$arr = $mail->sendEmail($to,$from,$subject,trim($msg));
$to = $email;
$from = "email@gmail.com";
$subject = "Registration confirmation";
$msg = "message goes here";
$mail = new EMAIL();
$arr = $mail->sendEmail($to,$from,$subject,trim(preg_replace('/\s+/',' ', $msg));
这将删除额外的空格,以及前导空格和尾随空格。您需要发布代码来帮助您。如果@steve所说的不起作用,则说明电子邮件类有问题。