dst2017 2015-09-08 16:49
浏览 64

使用队列时,Laravel邮件不起作用

i've had email working within laravel for a few months now, but decided it's probably time to move them into a queue rather than slowing down users' page loads.

However, as soon as i switch to the database queue driver i get the following error:

local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Method Swift_Message::__toString() must not throw an exception' in /Applications/MAMP/htdocs/tp/vendor/laravel/framework/src/Illuminate/Mail/Transport/MailgunTransport.php:0

If i switch back to sync driver, everything works again.

Could this be something to do with permissions, or different users running different jobs?

For reference the queuing is:

Mail::queue('emails.new_team', [], function($message) use ($team)
{
    $message->to('hiden@hidden.co', 'hiden');
    $message->from('hiden@hiden.co', 'hiden');
    $message->subject($team->name.' - Team Just Created!');
});

With new_team email containing (admin is one of my routes):

@extends('emails.baseemail')

@section('content')
            <h2 style="margin-bottom: 20px; font-weight: 900; font-size: 25px;">Theres a new team!!</h2>

<div style="margin: 20px 0;">
    <a href="{{ url('admin') }}">Go to Admin</a>
</div>
@stop

And Base email containing:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    @yield('specificMETA')
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
    <link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico">
</head>

<body style="font-family: 'Dosis', sans-serif; font-weight: 300; color: #666; background: #FDFDFD; margin: 0;" bgcolor="#FDFDFD">
<style type="text/css">
.button:hover {
background: #7f8c8d;
}
.cta:hover {
background: #2980b9;
}
</style>
<div id="header" style="position: inherit; z-index: 73411; font-size: 30px; line-height: 70px; color: #ecf0f1; width: 100%; height: 70px; background: #27ae60;">
        <div class="centre_col" style="width: 1024px; margin: 0 auto;">
            <div id="header_left" class="l" style="float: left;">
                <a href="/" title="Go to the xxx Homepage" class="logo" style="text-decoration: none"><img alt="tp" src="{{$message->embed(asset('img/tp.jpg'))}}"></a>
            </div>
        </div>
    </div>
    <div id="content" style="margin-top: 20px;">
        <div class="centre_col" style="width: 1024px; margin: 0 auto;">@yield('content')</div>
    </div>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • douqin0676 2015-09-08 17:17
    关注

    It turns out the problem was using asset() within the img tag in the base email.

    so <img alt="tp" src="{{$message->embed(asset('img/tp.jpg'))}}">

    becomes <img alt="tp" src="{{$message->embed('http://tp.co/img/tp.jpg')}}">

    So far i've just had to hard code the path to the image.

    Note that it has to be the full path, so i've chosen my live server's path.

    This isn't ideal, so if anyone knows how to do relative paths within queued emails, please let me know and i'll accept that answer.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog