php - Laravel mail cannot send from field -


im trying send mail laravel , when add dynamic field error:

"expected response code 250 got code "501", message "501 syntax error encountered in command argument.."

this code:

$user = input::get('user');  mail::send('template.contact',  $user , function($message) use ($user) {     $email = $user['email'];     $message->from($email , 'name'); thats doesnt     //$message->from('us@example.com', 'laravel'); work      $message->to('test@gmail.com', 'contact us' )->subject($user['subject']); }); 

and user coming angular - service:

 this.sendconatctmail = function(data) {         return $http.post('send-contact-mail', {user: data});       } 

and controller:

contactservice.sendconatctmail($scope.user); 

here's 1 way can solve this.

let's assume data on this.sendconatctmail = function(data) { object this:

var data {     email: 'some@email.com',     // other field: values } 

right before post it, should convert json string this:

return $http.post('send-contact-mail', {user: json.stringify(data)}); 

then on laravel/php side, decode array , use this:

if (input::has('user')) {     // decode json string     $user = @json_decode(input::get('user'), true);      // proceed if json decoding success     if ($user)     {         // send email         mail::send('template.contact',  $user , function($message) use (&$user)         {             $message->from($user['email'], 'name')                     ->to('test@gmail.com', 'contact us')                     ->subject($user['subject']);         });     } } 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -