1. Go to this page and download the library: Download mailgun/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/ */
mailgun / 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.'
]);
# Include the Autoloader (see "Libraries" for install instructions)
::create('KEY', 'FULL_DOMAIN_URL');
$domain = "DOMAIN";
# Issue the call to the client.
$result = $mgClient->domains()->updateWebScheme($domain, 'https');
print_r($result);
# Include the Autoloader (see "Libraries" for install instructions)
::create('KEY', 'FULL_DOMAIN_URL');
$domain = "DOMAIN";
# Issue the call to the client.
$result = $mgClient->domains()->updateWebPrefix($domain, 'tracking');
print_r($result);
# Include the Autoloader (see "Libraries" for install instructions)
te('KEY', 'ENDPOINT');
$domain = "DOMAIN";
$path = 'some path';
$params = [];
# Issue the call to the client.
$resultPost = $mgClient->httpClient()->httpPost($path, $params);
$resultGet = $mgClient->httpClient()->httpGet($path, $params);
$resultPut = $mgClient->httpClient()->httpPut($path, $params);
$resultDelete = $mgClient->httpClient()->httpDelete($path, $params);
use Mailgun\HttpClient\HttpClientConfigurator;
use Mailgun\Hydrator\NoopHydrator;
$configurator = new HttpClientConfigurator();
$configurator->setEndpoint('http://bin.mailgun.net/aecf68de');
$configurator->setApiKey('key-example');
$configurator->setSubAccountId($subAccountId)
use Mailgun\Hydrator\ArrayHydrator;
$configurator = new HttpClientConfigurator();
$configurator->setApiKey('key-example');
$mg = new Mailgun($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;
}
use Mailgun\HttpClient\HttpClientConfigurator;
use Mailgun\Hydrator\NoopHydrator;
$configurator = new HttpClientConfigurator();
$configurator->setEndpoint('http://bin.mailgun.net/aecf68de');
$configurator->setApiKey('key-example');
$configurator->setDebug(true);
$mg = new Mailgun($configurator, new NoopHydrator());
# 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.'
]);