0

我有一个 hello world 模板,我正在尝试在 for 循环中使用此模板发送电子邮件,我收到了三封邮件,但只有第一封邮件显示“hello world”,其他邮件为空。帮助!!!

function testMail(Request $request) {
    for ($i = 0; $i < 3; $i++) {
        $data = array();
        Mail::send('preview', $data, function($message) {
            $message->from('test@gmail.com');
            $message->to('test@gmail.com')->subject('Bla test: ');
        });
    }
}

注意:我会将不同的内容发送到不同的电子邮件。这就是我不制作数组的原因。

4

1 回答 1

-1

好吧,我从没想过问题出在我的模板上。“include_once”

<!DOCTYPE html>
<html lang="en">  
<body id="body">
      <?php include_once 'components/invoice_template.php';?>
</body>
</html>

为了这:

<!DOCTYPE html>
<html lang="en">  
<body id="body">
      <?php include 'components/invoice_template.php';?>
</body>
</html>

似乎 include_once 只工作一次。xD

于 2016-09-13T19:19:08.257 回答