dimanche 21 août 2016

Laravel 5.1 and sendgrid store attachments in inbound parse

I want to be able to receive e-mails in my own application trough SendGrid. Now, receiving e-mails work, except the fact that I can't get the attachments stored bu user etc...

So I want to store the attachments on my server to let a user see them as attachemnt in the e-mail.

I don't know how I should do this, so could anyone help me out?

I currently store the e-mails with this code:

public function ReceiveMail(Request $request)
    {
      DB::table('email')->insert([
          'headers' => $request->get('headers'),
          'html' => $request->get('html'),
          'from' => $request->get('from'),
          'sender_ip' => $request->get('sender_ip'),
          'to' => $request->get('to'),
          'cc' => $request->get('cc'),
          'subject' => $request->get('subject'),
          'dkim' => $request->get('dkim'),
          'spf' => $request->get('spf'),
          'envelope' => $request->get('envelope'),
          'charsets' => $request->get('charsets'),
          'spam_score' => $request->get('spam_score'),
          'spam_report' => $request->get('spam_report'),
          'attachments' => $request->get('attachments'),
          'attachment-info' => $request->get('attachment-info'),
          'attachmentX' => $request->get('attachmentX')
      ]);

      PushBullet::all()->note('E-mail', 'Nieuwe e-mail van '.Self::get_string_between($request->get('from'), '<', '>').' aan '.Self::get_string_between($request->get('to'), '<', '>').'.');

      return 'ok';
    }

Any suggestions to improve the code or to change things to make receiving e-mails better and more secure are also welcome!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire