Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

求助 发送邮件只有标题没有内容 #1

Open
daniuwo opened this issue Apr 18, 2021 · 6 comments
Open

求助 发送邮件只有标题没有内容 #1

daniuwo opened this issue Apr 18, 2021 · 6 comments

Comments

@daniuwo
Copy link

daniuwo commented Apr 18, 2021

收到的邮件只有标题没有内容

<?php

declare(strict_types=1);

namespace App\Mail;

use HyperfExt\Contract\ShouldQueue;
use HyperfExt\Mail\Mailable;

class UserEmailCode extends Mailable implements ShouldQueue
{
    public $code;

    /**
     * Create a new message instance.
     * @param mixed $code
     */
    public function __construct($code = '')
    {
        $this->code = $code;
    }

    /**
     * Build the message.
     */
    public function build()
    {
        return $this->subject('账号注册验证码')->textView('email/user_email_code');
    }
}

发送代码

Mail::to($this->request->input('email'))->queue(new MailUserEmailCode($code));

用的ThinkTemplate 引擎/storage/view/email/user_email_code.html

您的验证码是:{$code},请不要把验证码泄露给其他人,如非本人操作请不用理会!

@ericyzhu
Copy link
Member

config 确认过吗

@micross
Copy link

micross commented Aug 2, 2021

遇到同样问题

@gokure
Copy link

gokure commented Aug 26, 2021

应该是邮件模板修改后,缓存尚未生成,而生成文件是协程里完成的,估计还是hyperf的bug,我们临时的做法是提前生成模板视图

@RFireStorm
Copy link

就是视图缓存没生成导致的,在邮件的构造方法里预先编译对应的视图文件即可解决(如图。当然,只要你能在使用视图前确保视图缓存文件已生成,理论上都是可以的,比如你甚至可以在config/container.php里面批量生成,只是这样做破坏了框架原有的结构)。
image

@Hhhha
Copy link

Hhhha commented Dec 13, 2021

就是视图缓存没生成导致的,在邮件的构造方法里预先编译对应的视图文件即可解决(如图。当然,只要你能在使用视图前确保视图缓存文件已生成,理论上都是可以的,比如你甚至可以在config/container.php里面批量生成,只是这样做破坏了框架原有的结构)。 image

我也遇到这个问题, 你这个确实能解决。 大佬提个PR给统一解决了吧?

@fsp1234567
Copy link

还有其他最新的解决方法吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants