0

I have a hello world template and I'm trying to send emails with this template in a for loop, I receipt the three mails but only the first mail shows the "hello world" and the other are empty. HELP!!!

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: ');
        });
    }
}

Note: I will send different content to different emails. That's why I'm not making an array.

Nesuferit
  • 21
  • 1
  • 5

1 Answers1

-1

Well, I never thought that the problem was on my template. The "include_once"

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

For this:

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

It seems that the include_once only works once. xD

Nesuferit
  • 21
  • 1
  • 5