PHP code example of eldadfux / mailgun-lite
1. Go to this page and download the library: Download eldadfux/mailgun-lite 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/ */
eldadfux / mailgun-lite example snippets
$apiKey = 'your-api-key-here';
$apiDomain = 'your-api-sending-domain-here';
$mailgun = new \MailgunLite\MailgunLite($apiKey, $apiDomain);
$mailgun
->setFrom('[email protected]', 'Team Example')
->setReplyTo('[email protected]') // (optional)
->setSchedule(strtotime('next Thursday')) // unix time stamp (optional)
->addRecipient('[email protected]', 'User 1 Name')
->addRecipient('[email protected]', 'User 2 Name')
->addRecipient('[email protected]', 'User 3 Name')
->setSubject('Hello World')
->setText('I am a string')
->setHTML('<b>I am a string</b>')
;
// Send Mail
if(!$mailgun->send()) {
throw new Exception('Problem sending mail: ' . $mailgun->getError());
}
// Subscribe to newsletter
$mailgun->subscribe('[email protected]', '[email protected]');