rdok / elasticemail-php

PHP Library for Elastic Email platform API.
http://api.elasticemail.com/public/help#Email_header
MIT License
2 stars 5 forks source link

How to attach attachment to the email? #16

Closed muzammilaskari closed 3 years ago

muzammilaskari commented 3 years ago

Hi, I am working with your package, and it works great, but I need to know how do I attach an attachment to the email which I am sending, Your quick response will be highly appriciated. Thanks,

rdok commented 3 years ago

Reopening pending new minor release.

muzammilaskari commented 3 years ago

Hi, Can you please share code snippest which shows how to add attachments to the email? Currently I am using this coe $elasticEmail->email()->send([ 'to' => $recipient, 'subject' => $request->subject, 'body' => $request->description, 'from' => env('ADVERTISING_MAIL_FROM_ADDRESS') ]);

rdok commented 3 years ago

Thanks for highlighting this feature @muzammilaskari

Upgrade your version to latest release v2.2.0. This includes said feature.

Example usage, taken from integration tests

       $subject = "elasticemail-php: Integration test: validate email "
            . "attachment send.";
        $attachments = [
            __DIR__ . '/alpha-attachment.txt',
             __DIR__ . '/beta-attachment.txt'
        ];
        $elasticEmail = new ElasticEmail($_ENV['ELASTIC_EMAIL_API_KEY']);
        $response = $elasticEmail->email()->send([
            'to' => $_ENV['TEST_EMAIL_TO'],
            'from' => $_ENV['TEST_EMAIL_FROM'],
            'subject' => $subject,
            'bodyText' => 'Wake up Samurai!',
        ], $attachments);
muzammilaskari commented 3 years ago

Ah - Thanks man You saved my day Cheers

rdok commented 3 years ago

Thanks for using this package; please feel free to point any bugs/additional high used features to enable from the ElasicEmail API.