當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mailgun::sendMessage方法代碼示例

本文整理匯總了PHP中Mailgun\Mailgun::sendMessage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mailgun::sendMessage方法的具體用法?PHP Mailgun::sendMessage怎麽用?PHP Mailgun::sendMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mailgun\Mailgun的用法示例。


在下文中一共展示了Mailgun::sendMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: send

 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 <contato@infojr.com.br>', '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;
 }
開發者ID:InfoJrUFBA,項目名稱:git-github,代碼行數:13,代碼來源:email.php

示例2: doSend

 /**
  * 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());
 }
開發者ID:leoflapper,項目名稱:mailprovider,代碼行數:11,代碼來源:Mailgun.php

示例3: sendEmail

 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 <postmaster@sandbox826ba91f3f2e476dbd8feefea0b862c6.mailgun.org>", 'to' => "alexandr.sharygin@iqria.com", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
     $mgClient->sendMessage($data['mailGun']['domain'], ['from' => "Burger Joint <postmaster@sandbox826ba91f3f2e476dbd8feefea0b862c6.mailgun.org>", 'to' => "alexandr.vasiliev@iqria.com", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
     $mgClient->sendMessage($data['mailGun']['domain'], ['from' => "Burger Joint <postmaster@sandbox826ba91f3f2e476dbd8feefea0b862c6.mailgun.org>", 'to' => "lidiya.chuhlib@iqria.com", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
     $mgClient->sendMessage($data['mailGun']['domain'], ['from' => "Burger Joint <postmaster@sandbox826ba91f3f2e476dbd8feefea0b862c6.mailgun.org>", 'to' => "burgerjoint.delivery@gmail.com", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
     return $mgClient->sendMessage($data['mailGun']['domain'], ['from' => "Burger Joint <postmaster@sandbox826ba91f3f2e476dbd8feefea0b862c6.mailgun.org>", 'to' => "Burger <{$data['mailGun']['email']}>", 'subject' => 'Замовлення ' . $order, 'html' => $state ? $this->setMessage($message) : $message]);
 }
開發者ID:ArsenBatyuchok,項目名稱:burger-joint,代碼行數:10,代碼來源:email.class.php

示例4: send

 /**
  * 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);
 }
開發者ID:profectsro,項目名稱:mailgun-mailer,代碼行數:19,代碼來源:MgMailer.php

示例5: send

 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);
 }
開發者ID:domynation,項目名稱:domynation-framework,代碼行數:13,代碼來源:MailgunMailer.php

示例6: send

 /**
  * @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;
 }
開發者ID:yarcode,項目名稱:yii2-email-manager,代碼行數:22,代碼來源:MailGun.php

示例7: testShouldAddRecipientVariables

 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('test@example.com', ['key' => 'value'])->addTo('test@example.com'));
 }
開發者ID:fazland,項目名稱:notifire,代碼行數:13,代碼來源:MailgunHandlerTest.php

示例8: send

 /**
  * 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;
 }
開發者ID:codaxis,項目名稱:cakephp-mailgun,代碼行數:37,代碼來源:MailgunTransport.php

示例9: send

 /**
  * {@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];
 }
開發者ID:synapsestudios,項目名稱:synapse-base,代碼行數:19,代碼來源:MailgunSender.php

示例10: email_mailgun

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);
    }
    */
}
開發者ID:nickyudha,項目名稱:spalosophy,代碼行數:25,代碼來源:_mailgun.php

示例11: sendEmail

 /**
  * 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);
 }
開發者ID:ChrisClement,項目名稱:Core,代碼行數:34,代碼來源:Email.php

示例12: sendmail

 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));
 }
開發者ID:Llano,項目名稱:monithorweb,代碼行數:7,代碼來源:MailLib.php

示例13: postSendMail

 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' => 'newsletter@programmechameleon.com', '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.']);
     }
 }
開發者ID:phantomlight,項目名稱:programme-chameleon,代碼行數:25,代碼來源:NewsLetterController.php

示例14: sendReceipt

 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' => 'support@fullprintcamping.com', 'to' => $user->email, 'subject' => "Your order at FullPrintCamping.com", 'text' => "fullprintcamping.com/order-details/" . $cart->id));
     var_dump($response);
 }
開發者ID:hogggy,項目名稱:infinite-wonder,代碼行數:8,代碼來源:EmailUtil.php

示例15: SendEmail

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 <postmaster@sandbox40726.mailgun.org>', 'to' => $to_email, 'subject' => $subject, 'text' => $mail_text));
}
開發者ID:epsilon670,項目名稱:Poolski,代碼行數:9,代碼來源:send_mail.php


注:本文中的Mailgun\Mailgun::sendMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。