sendMessage() public method

This function allows the sending of a fully formed message OR a custom MIME string. If sending MIME, the string must be passed in to the 3rd position of the function call.
public sendMessage ( string $workingDomain, array $postData, array $postFiles = [] ) : stdClass
$workingDomain string
$postData array
$postFiles array
return stdClass
Example #1
1
 public function send()
 {
     # Include the Autoloader (see "Libraries" for install instructions)
     # Instantiate the client.
     $mgClient = new Mailgun('');
     $domain = "";
     # Make the call to the client.
     $result = $mgClient->sendMessage($domain, array('from' => 'InfoJr UFBA <*****@*****.**>', 'to' => 'Você <' . $this->email . '>', 'subject' => 'Capacitação em Git & GitHub - Inscrito', 'text' => $this->name, 'html' => '<html style="width:500px"><style>html{width:500px; text-align:center;} img{width: 100%;} a{padding:5px 15px;}</style><img style="width:100%" src="http://www.infojr.com.br/git-github/assets/img/git-confirm.jpg"></img>
             <a style="padding:5px 15px" href="www.infojr.com.br">www.infojr.com.br</a>
             <a style="padding:5px 15px" href="www.facebook.com/infojrnews">/infojrnews</a>
             </html>'));
     return $result;
 }
Example #2
0
 /**
  * Sends the email through the Mailgun API.
  * @return \stdClass the Mailgun API response object.
  */
 protected function doSend()
 {
     if (!$this->getDomain()) {
         throw new \Exception('Domain not provided for sending a message through Mailgun. Please set a domain by using the "setDomain($domain)" method.');
     }
     return $this->client->sendMessage($this->getDomain(), $this->getMessage(), $this->getFiles());
 }
 public function sendEmail($message, $state = true, $order)
 {
     $data = (require dirname(__DIR__) . '/params.php');
     $mgClient = new Mailgun($data['mailGun']['apiKey']);
     $mgClient->sendMessage($data['mailGun']['domain'], ['from' => "Burger Joint <*****@*****.**>", 'to' => "*****@*****.**", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
     $mgClient->sendMessage($data['mailGun']['domain'], ['from' => "Burger Joint <*****@*****.**>", 'to' => "*****@*****.**", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
     $mgClient->sendMessage($data['mailGun']['domain'], ['from' => "Burger Joint <*****@*****.**>", 'to' => "*****@*****.**", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
     $mgClient->sendMessage($data['mailGun']['domain'], ['from' => "Burger Joint <*****@*****.**>", 'to' => "*****@*****.**", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
     return $mgClient->sendMessage($data['mailGun']['domain'], ['from' => "Burger Joint <*****@*****.**>", 'to' => "Burger <{$data['mailGun']['email']}>", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
 }
Example #4
0
 /**
  * Implementation of Send method
  * ============================
  *
  * Parse Nette\Mail\Message and send vie Mailgun
  * @param \Nette\Mail\Message $mail
  */
 public function send(Message $mail)
 {
     $nMail = clone $mail;
     $cFrom = $nMail->getHeader('Return-Path') ?: key($nMail->getHeader('From'));
     $to = $this->generateMultiString((array) $nMail->getHeader('To'));
     $cc = $this->generateMultiString((array) $nMail->getHeader('Cc'));
     $bcc = $this->generateMultiString((array) $nMail->getHeader('Bcc'));
     $nMail->setHeader('Bcc', NULL);
     $data = $nMail->generateMessage();
     $cData = preg_replace('#^\\.#m', '..', $data);
     return $this->mg->sendMessage($this->domain, array('from' => $cFrom, 'to' => $to, 'cc' => $cc, 'bcc' => $bcc), $cData);
 }
 public function send(EmailMessage $message, $data = [])
 {
     $messageData = ['to' => $message->recipients, 'subject' => utf8_encode($message->subject), 'text' => utf8_encode($message->body)];
     // Set the mailgun domain
     $domain = !empty($data['domain']) ? $data['domain'] : $this->domain;
     if (!empty($message->bcc)) {
         $messageData['bcc'] = $message->bcc;
     }
     // Set the from
     $messageData['from'] = $message->hasSender() ? utf8_encode($message->getFullSender()) : $this->defaultSender;
     // Send the message
     $this->mailgun->sendMessage($domain, $messageData);
 }
Example #6
0
 /**
  * @param $from
  * @param $to
  * @param $subject
  * @param $text
  * @param array $files
  * @param null $bcc
  * @return bool
  */
 public function send($from, $to, $subject, $text, $files = [], $bcc = null)
 {
     $this->init();
     $postData = ['from' => $from, 'to' => $to, 'subject' => $subject, 'html' => $text];
     try {
         $this->_api->sendMessage($this->domain, $postData, $files);
     } catch (\Exception $e) {
         \Yii::error('Send error: ' . $e->getMessage(), 'email\\MailGun');
         \Yii::trace(VarDumper::dumpAsString($postData), 'email\\MailGun');
         return false;
     }
     return true;
 }
Example #7
0
 public function testShouldAddRecipientVariables()
 {
     $that = $this;
     $this->mailgun->sendMessage('www.example.org', Argument::type('array'), Argument::cetera())->shouldBeCalled()->will(function ($args) use($that) {
         $postData = $args[1];
         $that->assertArrayHasKey('recipient-variables', $postData);
         $that->assertJson($postData['recipient-variables']);
         $resp = new \stdClass();
         $resp->http_response_code = 200;
         return $resp;
     });
     $this->handler->notify(Email::create()->addVariablesForRecipient('*****@*****.**', ['key' => 'value'])->addTo('*****@*****.**'));
 }
 /**
  * Send email via Mailgun
  *
  * @param CakeEmail $email
  * @return array
  * @throws Exception
  */
 public function send(CakeEmail $email)
 {
     if (Configure::read('Mailgun.preventManyToRecipients') !== false && count($email->to()) > 1) {
         throw new Exception('More than one "to" recipient not allowed (set Mailgun.preventManyToRecipients = false to disable check)');
     }
     $mgClient = new Mailgun($this->_config['mg_api_key']);
     $headersList = array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject');
     $params = [];
     foreach ($email->getHeaders($headersList) as $header => $value) {
         if (isset($this->_paramMapping[$header]) && !empty($value)) {
             $key = $this->_paramMapping[$header];
             $params[$key] = $value;
         }
     }
     $params['text'] = $email->message(CakeEmail::MESSAGE_TEXT);
     $params['html'] = $email->message(CakeEmail::MESSAGE_HTML);
     $attachments = array();
     foreach ($email->attachments() as $name => $info) {
         $attachments['attachment'][] = '@' . $info['file'];
     }
     try {
         $result = $mgClient->sendMessage($this->_config['mg_domain'], $params, $attachments);
         if ($result->http_response_code != 200) {
             throw new Exception($result->http_response_body->message);
         }
     } catch (Exception $e) {
         throw $e;
     }
     return $result;
 }
 /**
  * {@inheritDoc}
  */
 public function send(EmailEntity $email)
 {
     $time = time();
     $message = $this->buildMessage($email);
     // Get domain from the "from" address
     if (!preg_match('/@(.+)$/', $email->getSenderEmail(), $matches)) {
         throw new \Exception("Invalid from address: {$email->getSenderEmail()}");
     }
     $domain = $matches[1];
     $result = $this->mailgun->sendMessage($domain, $message);
     $email->setStatus($result->http_response_code === 200 ? 'sent' : 'error');
     $email->setSent($time);
     $email->setUpdated($time);
     $this->mapper->update($email);
     return [$email, $result];
 }
Example #10
0
function email_mailgun($api_key, $api_domain, $params)
{
    $_mailgun_api_key = $api_key;
    $_mailgun_domain = $api_domain;
    $_mailgun_from = $params['from'];
    $_mailgun_to = $params['to'];
    $_mailgun_subject = $params['subject'];
    $_mailgun_text = $params['msg'];
    $mg = new Mailgun($_mailgun_api_key);
    $domain = $_mailgun_domain;
    # Now, compose and send your message.
    $mg->sendMessage($domain, array('from' => $_mailgun_from, 'to' => $_mailgun_to, 'subject' => $_mailgun_subject, 'html' => $_mailgun_text));
    /* --- COUNTER --- */
    /*
    $_date = date('Y-m-d');
    $_mailgun_count = $_mailgun->count_email($_date);
    
    if($_mailgun_count->rows > 0){
       $_mailgun_data = $_mailgun->get_email($_date);
    	  $_mailgun->update_counter($_mailgun_data->date, ($_mailgun_data->counter + 1), $_mailgun_data->status, $_mailgun_data->id);
    }else{
       $_update->insert_counter($_date, 1, 1);
    }
    */
}
Example #11
0
 /**
  * Sends an email using MailGun
  * @author salvipascual
  * @param String $to, email address of the receiver
  * @param String $subject, subject of the email
  * @param String $body, body of the email in HTML
  * @param Array $images, paths to the images to embeb
  * @param Array $attachments, paths to the files to attach 
  * */
 public function sendEmail($to, $subject, $body, $images = array(), $attachments = array())
 {
     // do not email if there is an error
     $response = $this->deliveryStatus($to);
     if ($response != 'ok') {
         return;
     }
     // select the from email using the jumper
     $from = $this->nextEmail($to);
     $domain = explode("@", $from)[1];
     // create the list of images
     if (!empty($images)) {
         $images = array('inline' => $images);
     }
     // crate the list of attachments
     // TODO add list of attachments
     // create the array send
     $message = array("from" => "Apretaste <{$from}>", "to" => $to, "subject" => $subject, "html" => $body, "o:tracking" => false, "o:tracking-clicks" => false, "o:tracking-opens" => false);
     // get the key from the config
     $di = \Phalcon\DI\FactoryDefault::getDefault();
     $mailgunKey = $di->get('config')['mailgun']['key'];
     // send the email via MailGun
     $mgClient = new Mailgun($mailgunKey);
     $result = $mgClient->sendMessage($domain, $message, $images);
 }
Example #12
0
 public function sendmail($to, $from, $subject, $message)
 {
     $mgClient = new Mailgun('key-6fe06142d08a9e9c3989f3731bd1d6c0');
     $domain = "monithor.net";
     # Make the call to the client.
     $result = $mgClient->sendMessage($domain, array('from' => $from, 'to' => $to, 'subject' => $subject, 'text' => $message));
 }
 public function postSendMail()
 {
     if (!\Input::has('subject') && !\Input::has('message')) {
         return \Response::json(['type' => 'danger', 'message' => 'Email data not complete.']);
     }
     $recipients = \NewsLetter::getAllRecipients();
     if (count($recipients) > 0) {
         $recipientsTo = [];
         foreach ($recipients as $recipient) {
             $recipientsTo[$recipient->email] = ['email' => $recipient->email];
         }
         try {
             $mg = new Mailgun(env('MAILGUN_PRIVATE_KEY'));
             $data = ['content' => \Input::get('message')];
             $inliner = new EmailInliner('emails.newsletter', $data);
             $content = $inliner->convert();
             $mg->sendMessage('programmechameleon.com', ['from' => '*****@*****.**', 'to' => implode(",", array_keys($recipientsTo)), 'subject' => \Input::get('subject'), 'html' => $content, 'text' => 'Programme Chameleon Text Message', 'recipient-variables' => json_encode($recipientsTo)]);
             return \Response::json(['type' => 'success', 'message' => 'Message successfully sent.']);
         } catch (\Exception $e) {
             return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]);
         }
     } else {
         return \Response::json(['type' => 'danger', 'message' => 'No emails to send.']);
     }
 }
Example #14
0
 public function sendReceipt(Cart $cart)
 {
     $mg = new Mailgun(self::API_KEY);
     $domain = "mg.fullprintcamping.com";
     $user = $cart->user()->first();
     $response = $mg->sendMessage($domain, array('from' => '*****@*****.**', 'to' => $user->email, 'subject' => "Your order at FullPrintCamping.com", 'text' => "fullprintcamping.com/order-details/" . $cart->id));
     var_dump($response);
 }
Example #15
0
function SendEmail($to_email, $subject, $mail_text)
{
    # Instantiate the client.
    $mgClient = new Mailgun('key-9ugjcrpnblx1m98gcpyqejyi75a96ta5');
    //$domain = "sandbox40726.mailgun.org";
    $domain = "Poolski.com";
    # Make the call to the client.
    $result = $mgClient->sendMessage("{$domain}", array('from' => 'Poolski <*****@*****.**>', 'to' => $to_email, 'subject' => $subject, 'text' => $mail_text));
}
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function notify(NotificationInterface $notification)
 {
     if (!class_exists('Swift_Message')) {
         throw new \RuntimeException('You need to install swift mailer to use mailgun transport');
     }
     /** @var Email $notification */
     $message = \Swift_Message::newInstance($notification->getSubject())->setFrom($notification->getFrom());
     foreach ($notification->getParts() as $part) {
         $message->attach(\Swift_MimePart::newInstance($part->getContent(), $part->getContentType()));
     }
     foreach ($notification->getAttachments() as $attachment) {
         $message->attach(\Swift_Attachment::newInstance($attachment->getContent(), $attachment->getName(), $attachment->getContentType()));
     }
     $postData = ['o:tag' => $notification->getTags()];
     foreach ($notification->getMetadata() as $key => $value) {
         $postData['v:' . $key] = $value;
     }
     if ($recipientVariables = $notification->getRecipientVariables()) {
         $postData['recipient-variables'] = json_encode($recipientVariables);
     }
     $failed = [];
     $success = [];
     $to = array_merge(array_values($notification->getTo()), array_values($notification->getCc()), array_values($notification->getBcc()));
     if (!empty($to)) {
         foreach (array_chunk($to, 1000) as $to_chunk) {
             $result = new Result('mailgun', $this->getName());
             $data = $postData;
             $data['to'] = $to_chunk;
             $res = $this->mailgun->sendMessage($this->domain, $data, $message->toString());
             if ($res->http_response_code == 200) {
                 $success[] = $res;
             } else {
                 $result->setResult(Result::FAIL);
                 $failed[] = $res;
             }
             $result->setResponse($res);
             $notification->addResult($result);
         }
         if (count($success) === 0) {
             throw new NotificationFailedException("Sending failed for message {$notification->getSubject()}", $failed);
         }
     }
 }
Example #17
0
 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  * 		http://example.com/index.php/welcome
  *	- or -
  * 		http://example.com/index.php/welcome/index
  *	- or -
  * Since this controller is set as the default controller in
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function index()
 {
     $this->load->library('encrypt');
     $mg = new Mailgun("key-03bbdd374175cab763318e141fb293ec");
     $domain = "sandbox750e37e111ff4d03a61fe980e1f94dee.mailgun.org";
     # Now, compose and send your message.
     $mg->sendMessage($domain, array('from' => '*****@*****.**', 'to' => '*****@*****.**', 'subject' => 'The PHP SDK is awesome!', 'text' => 'It is so simple to send a message.'));
     //print_r($result);
     $this->load->view('welcome_message');
 }
Example #18
0
 public function send(Mail $mail)
 {
     $client = new Client();
     $mg = new MG($this->config['mailgun_key'], $client);
     $status = $mg->sendMessage($this->config['mailgun_domain'], array('from' => $this->config['from'], 'to' => $mail->to, 'subject' => $mail->subject, 'html' => $mail->content));
     if (!$status) {
         return false;
     }
     return true;
 }
 /**
  *Handler to an event, when a country is not found in the Country Filter of a survey.
  */
 public function countryNotFoundHandler($survey_id)
 {
     # Instantiate the client.
     $mgClient = new Mailgun('key-ef43176cf355dd4eab5649acb1c89d0c');
     $domain = "hopstek.com";
     $to = "*****@*****.**";
     $subject = "Country Filter is not working";
     $message = "Hi,\r\n\r\n" . "One of the survey's country filter is not working correctly.\r\n\r\n" . "Visit to the survey by clicking on below URL:\r\n\r\n" . "http://" . $_SERVER['HTTP_HOST'] . "/" . str_replace("\\", "/", substr(getcwd(), strlen($_SERVER['DOCUMENT_ROOT']))) . "/view_survey_details.php?survey_id=" . $survey_id . "\r\n\r\n" . "Regards,\r\nSMT";
     # Make the call to the client.
     $result = $mgClient->sendMessage($domain, array('from' => 'SMT <*****@*****.**>', 'to' => $to, 'subject' => $subject, 'text' => $message));
 }
 public function sendEmail($templateFile)
 {
     extract($this->data);
     # Instantiate the client.
     $mgClient = new Mailgun('MAILGUN_KEY');
     $domain = MAILGUN_DOMAIN;
     ob_start();
     include $templateFile;
     $emailBody = ob_get_clean();
     # Make the call to the client.
     $result = $mgClient->sendMessage($domain, array('from' => $emailHeader['from'], 'to' => $emailHeader['to'], 'subject' => $emailHeader['subject'], 'text' => $emailBody));
 }
Example #21
0
 public function sendVerificationEmail($where, $what)
 {
     # First, instantiate the SDK with your API credentials and define your domain.
     $msg = new Mailgun(Config::get('mailgun/secret'));
     $domain = Config::get('info/domain');
     # Now, compose and send your message.
     $msg->sendMessage($domain, array('from' => Config::get('mailgun/from_email'), 'to' => $where, 'subject' => "Your BernBuds email validation code is: {$what}", 'text' => "Your BernBuds email validation code is: {$what}"));
     $result = $msg->get("{$domain}/log", array('limit' => 1, 'skip' => 0));
     $httpResponseCode = $result->http_response_code;
     $httpResponseBody = $result->http_response_body;
     return $httpResponseBody;
 }
Example #22
0
 public function sendInviteEmail($to_emails, $from_user, $code, $goupname)
 {
     $mg = new Mailgun($this->api_key);
     $domain = "collabii.com";
     $rt = array();
     foreach ($to_emails as $email) {
         # Now, compose and send your message.
         $rt[] = $mg->sendMessage($domain, array('from' => '*****@*****.**', 'to' => $to_emails, 'subject' => 'Collabii Invite From ' . $from_user->get('name'), 'html' => '<img src="http://www.collabii.com/img/logo.png" alt="Collabii"/><p>Hi, ' . $from_user->get('name') . ' has invited you to join a Collabii group.  Just click on the invite link below.</p>
                             <a href="http://www.collabii.com/joingroup/email/' . $code . '">' . $goupname . '</a>'));
     }
     return $rt;
 }
Example #23
0
 /**
  * Send a mail using this transport
  *
  * @return void
  */
 public function sendMessage()
 {
     // If Mailgun Service is disabled, use the default mail transport
     if (!$this->config->enabled()) {
         parent::sendMessage();
         return;
     }
     $messageBuilder = $this->createMailgunMessage($this->parseMessage());
     $mailgun = new Mailgun($this->config->privateKey(), $this->getHttpClient(), $this->config->endpoint());
     $mailgun->setApiVersion($this->config->version());
     $mailgun->setSslEnabled($this->config->ssl());
     $mailgun->sendMessage($this->config->domain(), $messageBuilder->getMessage(), $messageBuilder->getFiles());
 }
Example #24
0
 /**
  * @inheritdoc
  */
 public function send(MessageInterface $message)
 {
     $httpClient = new \Http\Adapter\Guzzle6\Client();
     $mg = new Mailgun($this->apiKey, $httpClient);
     list($name, $domain) = explode('@', $message->getFromPerson()->getEmail());
     # Now, compose and send your message.
     try {
         $response = $mg->sendMessage($domain, ['sender' => $message->getFromPerson()->getEmail(), 'from' => $this->nameWithEmail($message->getFromPerson()->getEmail(), $message->getFromPerson()->getFullName()), 'to' => $message->getToPerson()->getEmail(), 'subject' => $message->getSubject(), 'html' => $message->getHtmlContent(), 'text' => $message->getTextContent()]);
         $result = new SendingResult($response);
     } catch (\Exception $e) {
         $result = new SendingResult();
     }
     return $result;
 }
Example #25
0
 public static function sendToAdmin(array $data)
 {
     // Define properties
     $data = self::sanitize($data);
     $site = get_option("blogname");
     $from = "System Message <" . get_option("admin_email") . ">";
     $to = get_option("admin_email");
     // Create text
     $subject = "Customer used form on the site \"{$site}\"";
     $message = Template::renderPart("email/form", ['site' => $site, 'data' => $data]);
     // Send mail
     $Mailgun = new Mailgun(get_option("mailgun_key"));
     $result = $Mailgun->sendMessage(get_option("mailgun_domain"), ['from' => $from, 'to' => $to, 'subject' => $subject, 'html' => $message]);
     // Return sending result
     return $result;
 }
Example #26
0
 /**
  * @param Request $request
  *
  * @throws \Mailgun\Messages\Exceptions\MissingRequiredMIMEParameters
  */
 public function getConfirm(Request $request)
 {
     $mg = new Mailgun(config('services.mailgun.secret'));
     $domain = config('services.mailgun.domain');
     $optInHandler = $mg->OptInHandler();
     $inboundHash = $request->get('hash');
     $secretPassphrase = env('APP_KEY');
     $hashValidation = $optInHandler->validateHash($secretPassphrase, $inboundHash);
     if ($hashValidation) {
         $validatedList = $hashValidation['mailingList'];
         $validatedRecipient = $hashValidation['recipientAddress'];
         $body = "<html><body>Olá,<br><br>Adicionamos seu email na nossa lista, {$validatedList}!<br><br>Obrigado!</body></html>";
         $mg->put("lists/{$validatedList}/members/{$validatedRecipient}", array('address' => $validatedRecipient, 'subscribed' => 'yes'));
         $mg->sendMessage($domain, array('from' => config('services.mailgun.contact'), 'to' => $validatedRecipient, 'subject' => 'Confirmado!', 'html' => $body));
         return Response::make($body);
     }
     return Response::make("N&atilde;o foi poss&iacute;vel confirmar sua inscri&ccedil;&atilde;o, tente novamente mais tarde.");
 }
 /**
  * Connect and submit email to Mailgun API Endpoint
  *
  * @param array $config API endpoint credentials
  * @param array $params params as per mailgun key value format
  * @param array $attachments attachments as per mailgun format
  * @return \stdClass $result containing status code and message
  * @throws Exception
  */
 private function mailgun($config, $params, $attachments)
 {
     if (empty($config['mailgun_api_key']) || empty($config['mailgun_domain'])) {
         throw new Exception('Mailgun API Key & Domain cannot be empty');
     }
     try {
         if (isset($config['mailgun_postbin_id']) && !empty($config['mailgun_postbin_id'])) {
             $mailgun = new Mailgun\Mailgun($config['mailgun_api_key'], 'bin.mailgun.net', $config['mailgun_postbin_id'], false);
         } else {
             $mailgun = new Mailgun\Mailgun($config['mailgun_api_key']);
         }
         $result = $mailgun->sendMessage($config['mailgun_domain'], $params, $attachments);
         if ($result->http_response_code != 200) {
             throw new Exception($result->http_response_body->message);
         }
     } catch (Exception $exc) {
         throw $exc;
     }
     return $result;
 }
Example #28
0
 /**
  * Sends an email using MailGun
  *
  * @author salvipascual
  * @param String $to, email address of the receiver
  * @param String $subject, subject of the email
  * @param String $body, body of the email in HTML
  * @param Array $images, paths to the images to embeb
  * @param Array $attachments, paths to the files to attach
  * */
 public function sendEmail($to, $subject, $body, $images = array(), $attachments = array())
 {
     // do not email if there is an error
     $utils = new Utils();
     $status = $utils->deliveryStatus($to);
     if ($status != 'ok') {
         return false;
     }
     // select the right email to use as From
     $from = $this->nextEmail($to);
     // create the list of images and attachments
     $embedded = array();
     if (!empty($images)) {
         $embedded['inline'] = $images;
     }
     if (!empty($attachments)) {
         $embedded['attachment'] = $attachments;
     }
     // create the array send
     $message = array("from" => "Apretaste <{$from}>", "to" => $to, "subject" => $subject, "html" => $body, "o:tracking" => false, "o:tracking-clicks" => false, "o:tracking-opens" => false, "h:X-service" => "Apretaste");
     // adding In-Reply-To header (creating conversation with the user)
     if ($this->messageid) {
         $message["h:In-Reply-To"] = $this->messageid;
     }
     // send the email via MailGun. Never send emails from the sandbox
     $di = \Phalcon\DI\FactoryDefault::getDefault();
     if ($di->get('environment') != "sandbox") {
         $mailgunKey = $di->get('config')['mailgun']['key'];
         $mgClient = new Mailgun($mailgunKey);
         $result = $mgClient->sendMessage($this->domain, $message, $embedded);
         // @TODO return false when negative $result
     }
     // save a trace that the email was sent
     $haveImages = empty($images) ? 0 : 1;
     $haveAttachments = empty($attachments) ? 0 : 1;
     $this->conn->deepQuery("INSERT INTO delivery_sent(mailbox,user,subject,images,attachments,domain) VALUES ('{$from}','{$to}','{$subject}','{$haveImages}','{$haveAttachments}','{$this->domain}')");
     return true;
 }
Example #29
0
    } else {
        // Login failed
        // $message = nl2br("Login Failed. Username and/or Password incorrect");
        if ($_SESSION['blockedme'] == true) {
            # Instantiate the client.
            $to = $user_email;
            $from_name = "Pioneer Academics";
            $from_mail = "*****@*****.**";
            $subject = "Account blocked - Pioneer Academics - " . $now;
            $message = " <div style='display:block; width:100%; height:100px; position:relative; background:url(http://pioneeracademics.com/imgs/logo.png) no-repeat top left; background-size: contain;'></div>\r\n        <br>\r\n\r\n       Unfortunately your account has been blocked for too many login attempts. <br>\r\n       Please contact us at info@pioneeracademics.com to unblock it and to receive further information regarding your account.<br><br>\r\n\r\n        Warmest Regards,<br>\r\n        Pioneer Academics<br>\r\n        ------------------------------------------<br>\r\n        ";
            $template_disclaimer = "<br><a href='http://pioneeracademics.com'> http://pioneeracademics.com</a><br><br> \r\n        <div style='border-top:#e2e2e2 solid 1px;color: #d0d0d0; display:block; width:100%; height:100px; position:relative; text-align:center; padding-top:20px; margin-top:30px;'>\r\n        This e-mail message and its attachments are for the sole use of the intended recipient and may contain confidential and privileged information.<br> If you received this message by error, please delete it from your computer, and inform the sender. <br> Any unauthorized review, use, disclosure or distribution of this message and/or its attachments is prohibited.</div>\r\n        ";
            $message .= $template_disclaimer;
            $mgClient = new Mailgun('key-b223a6c17abba6ac7b9c0aebee59b461');
            $domain = "pioneeracademics.com";
            # Make the call to the client.
            $result = $mgClient->sendMessage($domain, array('from' => 'Pioneer Academics <*****@*****.**>', 'to' => $to, 'bcc' => '*****@*****.**', 'subject' => $subject, 'html' => $message));
            echo '<script type=text/javascript>
        alert("Your account has been blocked for too many login attempts. \\nPlease contact us at info@pioneeracademics.com to unblock it");
        window.history.back();</script>';
            # code...
        } else {
            echo '<script type=text/javascript>
        alert("Login Failed. \\nUsername and/or Password are incorrect");
        window.history.back();</script>';
            //header('Location: ../index.php?error=1');
        }
    }
} else {
    // The correct POST variables were not sent to this page.
    echo 'Invalid Request';
}
Example #30
0
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
echo 'Moodoo Mailer Running - v2<br/>';
//phpinfo();
echo 'Moodoo Mailer check 1<br/>';
# Include the Autoloader (see "Libraries" for install instructions)
require 'autoload.php';
use Mailgun\Mailgun;
echo 'Moodoo Mailer check 2<br/>';
# Instantiate the client.
$mgClient = new Mailgun('key-851dde721772fe86ec36d307cebcc91a');
$domain = "mg.moodoo.net";
echo 'Moodoo Mailer check 3<br/>';
# Make the call to the client.
$result = $mgClient->sendMessage("{$domain}", array('from' => 'Mailgun Sandbox <*****@*****.**>', 'to' => 'John <*****@*****.**>', 'subject' => 'Hello John', 'text' => 'Congratulations John, you just sent an email with Mailgun!  You are truly awesome!  You can see a record of this email in your logs: https://mailgun.com/cp/log .  You can send up to 300 emails/day from this sandbox server.  Next, you should add your own domain so you can send 10,000 emails/month for free.'));
$result = $mg->get("{$domain}/log", array('limit' => 25, 'skip' => 0));
$httpResponseCode = $result->http_response_code;
$httpResponseBody = $result->http_response_body;
# Iterate through the results and echo the message IDs.
$logItems = $result->http_response_body->items;
foreach ($logItems as $logItem) {
    echo $logItem->message_id . "\n";
}
echo 'Moodoo Mailer Finished';
?>