1. Go to this page and download the library: Download neurohotep/mailgun-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
neurohotep / mailgun-php example snippets
use Mailgun\Mailgun;
// First, instantiate the SDK with your API credentials
$mg = Mailgun::create('key-example'); // For US servers
$mg = Mailgun::create('key-example', 'https://api.eu.mailgun.net'); // For EU servers
// Now, compose and send your message.
// $mg->messages()->send($domain, $params);
$mg->messages()->send('example.com', [
'from' => '[email protected]',
'to' => '[email protected]',
'subject' => 'The PHP SDK is awesome!',
'text' => 'It is so simple to send a message.'
]);
use Mailgun\Hydrator\ArrayHydrator;
$configurator = new HttpClientConfigurator();
$configurator->setApiKey('key-example');
$mg = Mailgun::configure($configurator, new ArrayHydrator());
$data = $mg->domains()->show('example.com');
foreach ($data['receiving_dns_records'] as $record) {
echo isset($record['record_type']) ? $record['record_type'] : null;
}
$configurator = new HttpClientConfigurator();
$configurator->setEndpoint('http://bin.mailgun.net/aecf68de');
$configurator->setDebug(true);
$mg = Mailgun::configure($configurator);
# Now, compose and send your message.
$mg->messages()->send('example.com', [
'from' => '[email protected]',
'to' => '[email protected]',
'subject' => 'The PHP SDK is awesome!',
'text' => 'It is so simple to send a message.'
]);