使用laravel邮件功能时出现标题错误
使用laravel邮件功能时,我收到以下错误:使用laravel邮件功能时出现标题错误,laravel,Laravel,使用laravel邮件功能时,我收到以下错误: Header may not contain more than a single header, new line detected 以下是从错误日志中获取的stacktrace: [2015-03-04 23:52:31] production.ERROR: exception 'ErrorException' with message 'Header may not contain more than a single header,
Header may not contain more than a single header, new line detected
以下是从错误日志中获取的stacktrace:
[2015-03-04 23:52:31] production.ERROR: exception 'ErrorException'
with message 'Header may not contain more than a single header, new line detected' in /var/www/pickup/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php:342
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'Header may not ...', '/var/www/pickup...', 342, Array)
#1 /var/www/pickup/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php(342): header('statusText: Exp...', false, 412)
#2 /var/www/pickup/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php(375): Symfony\Component\HttpFoundation\Response->sendHeaders()
#3 /var/www/pickup/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(643): Symfony\Component\HttpFoundation\Response->send()
#4 /var/www/pickup/public/index.php(49): Illuminate\Foundation\Application->run()
#5 {main} [] []
我的邮件功能是:
public function sendmail($user){
Mail::queue('emails.verify', array('encryption'=>self::encrypt($user->email) , 'name'=>$user->first_name), function($message) use($user)
{
$message->to($user->email, $user->first_name)->subject('[Pickup] Please verify your email '.$user->email);
});
}
听起来好像发送到to方法的变量之一包含换行符,而to方法希望您自己清理这些值 我从一个简单的修剪电话开始 <>如果这不起作用,那就意味着其中一个变量中间有换行符。我会尝试记录这些值,然后根据您发现的内容清理变量。另外,如果您只是想跳过坏数据,那么将所有内容包装在try/catch中是另一种方法
try
{
$message->to(trim($user->email), trim($user->first_name))->subject(
'[Pickup] Please verify your email '.trim($user->email));
}
catch (\Exception $e)
{
\Log::error($e->getMessage());
}
修剪方法没有效果。还是一样的错误。我调用邮件函数的位置已经在try-catch块中。
try
{
$message->to(trim($user->email), trim($user->first_name))->subject(
'[Pickup] Please verify your email '.trim($user->email));
}
catch (\Exception $e)
{
\Log::error($e->getMessage());
}