2016-09-24 7 views
0

'emailsscribed'보기에서 실제/현재 이메일 주소를 얻는 방법은 무엇입니까?Laravel 5.2 여러 이메일 전송. 보기에서 이메일 주소 받기

Mail::send('emails.subscribed', $data, function($message) use ($subject,$recievers,$meta) { 
    foreach ($recievers as $email) { 
     $message->bcc($email,$email); 
     $message->email = $email; 
    } 
}); 

그리고 현재 이메일 주소 (단지는 현재 전체 이메일 배열)하는 데 필요한보기 : {{$somehow->email}}

+0

이 작업을 수행하려면 foreach 루프에서 전체 Mail fascade를 만들고 현재 전자 메일을 전달하는 것이 좋습니다. 왜냐하면 개별 수신자에 따라보기가 작성되어야하기 때문입니다. –

+0

다음과 같이 말할 수 있습니다. foreach() {Mail :: send()} 수신자가 많은 경우이 방법을 너무 느리게하지 않습니까? – robcaa

+0

예, 실제로해야합니다. 그리고 예, 속도가 느릴 수 있지만보기가 개별적으로 만들어 져야합니다. 그래서 나는 결국 최상의 옵션이라고 생각합니다. 행운을 빕니다! –

답변

0

이 모든, 하나의 이메일 하나를 보내기 여기 내 코드입니다

$recipients = [ ["name" => "John", "email" => "[email protected]"], ["name" => "Doe", "email" => "[email protected]"] ]; 

$subject = 'subject'; 
$meta = 'meta'; 

foreach($recipients as $recipient) { 
    // here you declare variables accesable in view file 
    $dataToPassToEmailView = []; 
    // **key** of this table is variable **name in view** 
    $dataToPassToEmailView['recipient'] = $recipient; 

    Mail::send('emails.subscribed', $dataToPassToEmailView, function($message) use ($subject, $recipient, $meta) { 
     $message->to($recipient['email'], $recipient['name']); 
     $message->subject($subject); 
    }); 
} 

보기 emails.subscribed.blade.php :

Email: {{ $recipient['email'] }} 
Name: {{ $recipient['name'] }} 
012 숨은에서, 당신은 쉽게 이메일보기를 변경할 수 있습니다