clarification / sendgrid-laravel-driver

11 stars 7 forks source link

Attachment is not being attached #5

Open sarahman opened 6 years ago

sarahman commented 6 years ago

While a pdf file is being tries to be attached through the attachData method, it does not add to the Mail. My code is:

\Mail::send(['html' => 'This is just a sample email with an attachment.', 'raw' => true], [], function ($message) use ($invoicePdf) {
    /** @var \Illuminate\Mail\Message $message */
    $message->to('aabid048@gmail.com'));
    $message->subject('Sample Email of Invoice');
    $message->attachData(base64_encode($invoicePdf), 'Invoice.pdf');
});

Please help you send email through your library. Thanks in advance!

Lidbetter commented 6 years ago

I think this commit should fix the issue: https://github.com/clarification/sendgrid-laravel-driver/commit/2628545de51694497448d4fc513cb518897fd521

Please can you confirm it does fix the issue (packagist dev-master)

let me know and I will tag a release.

sarahman commented 6 years ago

Thank you for your reply. I'll check that out and inform you!!!

sarahman commented 6 years ago

My output becomes the following right before sending the email:

array:2 [
  "headers" => array:1 [
    "Authorization" => "Bearer [API_KEY]"
  ]
  "form_params" => array:7 [
    "from" => "aabid048@gmail.com"
    "fromname" => "Syed Abidur Rahman"
    "subject" => "Sample Email of Invoice"
    "html" => """
      Sample Invoice\r\n
      """
    "to" => array:1 [
      0 => "aabid048@gmail.com"
    ]
    "toname" => array:1 [
      0 => "Syed Abidur Rahman"
    ]
    "files" => array:1 [
      "Invoice.pdf" => stream resource @480
        timed_out: false
        blocked: true
        eof: false
        wrapper_type: "plainfile"
        stream_type: "STDIO"
        mode: "r+b"
        unread_bytes: 0
        seekable: true
        uri: "/tmp/phpNFORSp"
        options: []
      }
    ]
  ]
]

Is it Ok? It still sends email without attachment.