Laravel 4:使用数组发送到CC的邮件发送错误,不符合RFC 2822,3.6.2

时间:2016-05-19 21:24:55

标签: php laravel-4

这让我一直疯狂...... 我尝试阅读有关SwraMailer for Laravel的所有内容,包括基于主题的其他错误的修复,但我不知道如何通过电子邮件地址数组传递错误。

有没有办法确定CC如何显示我的电子邮件地址?每当我print_r它时,它会显示“name@domain.com; name2@domain.com “

// current logged id
$user_id = $id;

// match all current logged id to all assets
// if investment type is present, get property id
$asset = ClientPropertyManagement::where('assets.client_id', '=', $user_id)->get();

foreach( $asset as $assets ) {
  if( $assets->investment_type == "TIC"  ) {
    $properties[] = $assets->property_id; 
  }
}

// if property id is present, connect to property table
// if connected and match id, get property manager emails
if( !empty($properties) ){
  $property = DB::table('property')->whereIn('id', $properties)->get();
  foreach( $property as $p ){
    $contact[] = $p->property_mgmt_contact;
  }
}

// if property managers are present, filter
// name@domain.com; name2@domain.com
if( !empty($contact) ) {
  $property_contact = implode(', ', array_filter(array_unique($contact)));
}

print_r($property_contact);
// output: "name@domain.com; name2@domain.com "

//send email to owner and other property manager                
Mail::send('_dash.emails.profile', $contacts, function ($message) {                             
  $ownerEmail = "name@gmail.com";
  $ownerName = "WebMail Information";
  $recipient_name  = Request::get('firstname') .' '. Request::get('lastname');
  $recipient_email = explode(';', Input::get('email'));

  $message->from($recipient_email[0],$recipient_name);
  $message->cc($property_contact); // send property all managers
  $message->to($ownerEmail,$ownerName)->subject("Profile Update");                 
});

注意:我转储dd($property_contact)后,价值为null ...怎么回事?即使我粘贴Mail::send内的代码仍为空。

1 个答案:

答案 0 :(得分:0)

我忘记在use ($variable)内添加Mail::send,将我的变量传递到Mail::send之外。

//send email to owner and other property manager                
Mail::send('_dash.emails.profile', $contacts, function ($message) use ($property_contact) {                             
  $ownerEmail = "name@gmail.com";
  $ownerName = "WebMail Information";
  $recipient_name  = Request::get('firstname') .' '. Request::get('lastname');
  $recipient_email = explode(';', Input::get('email'));

  $message->from($recipient_email[0],$recipient_name);
  $message->cc($property_contact); // send property all managers
  $message->to($ownerEmail,$ownerName)->subject("Profile Update");                 
});