Skip to content

Instantly share code, notes, and snippets.

@pontikis
Last active August 20, 2018 16:54
Show Gist options
  • Save pontikis/5a6e57be756e1c3ed387400f912c8a7b to your computer and use it in GitHub Desktop.
Save pontikis/5a6e57be756e1c3ed387400f912c8a7b to your computer and use it in GitHub Desktop.
Send mail with PHP Mailgun API
<?php
$mg = Mailgun::create('YOUR_PRIVATE_API_KEY');
$mg_domain = 'mail.company.com';
$mg_response = $mg->messages()->send($mg_domain,
[
'subject' => 'Subject here',
'from' => 'Company Support <[email protected]>',
'to' => 'John Doe <[email protected]>',
'h:Reply-To' => 'Do NOT reply <[email protected]>',
'text' => 'plain text message',
'html' => '<html><body>html message</body</html>',
'inline' => [
[
'filePath' => '/path/to/logo-640x350.jpg',
'filename' => 'logo.jpg',
],
[
'filePath' => '/path/to/facebook-32x32.png',
'filename' => 'facebook.png',
],
],
'attachment' => [
[
'filePath' => '/path/to/inv_314567.pdf',
'filename' => 'invoice.pdf',
],
],
]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment