当前位置: 首页>>代码示例>>PHP>>正文


PHP Mailgun::post方法代码示例

本文整理汇总了PHP中Mailgun\Mailgun::post方法的典型用法代码示例。如果您正苦于以下问题:PHP Mailgun::post方法的具体用法?PHP Mailgun::post怎么用?PHP Mailgun::post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mailgun\Mailgun的用法示例。


在下文中一共展示了Mailgun::post方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 /**
  * @param string|array $view
  * @param array        $data
  * @param \Closure     $callback
  * @param null         $message
  *
  * @return \Bogardo\Mailgun\Http\Response
  */
 public function send($view, array $data, Closure $callback, $message = null)
 {
     $this->message = $message ?: new Message($this->mailgun->MessageBuilder(), $this->config);
     $this->callMessageBuilder($callback, $this->message);
     $this->renderBody($view, $data);
     $message = $this->message->getMessage();
     $files = $this->message->getFiles();
     $domain = $this->config->get('mailgun.domain');
     $response = new Response($this->mailgun->post("{$domain}/messages", $message, $files));
     return $response;
 }
开发者ID:bogardo,项目名称:mailgun,代码行数:19,代码来源:Mailer.php

示例2: addList

 public function addList()
 {
     # Instantiate the client.
     $mgClient = new Mailgun('YOUR_API_KEY');
     # Issue the call to the client.
     $result = $mgClient->post("lists", array('address' => 'LIST@YOUR_DOMAIN_NAME', 'description' => 'Mailgun Dev List'));
 }
开发者ID:shockwave-design,项目名称:magento2-module-mail-mailgun,代码行数:7,代码来源:MailgunList.php

示例3: setAdressToOkMailGun

 public function setAdressToOkMailGun($recipient)
 {
     $mgClient = new Mailgun(env('Mailgun_Secret_API_Key', false));
     $defaultAddress = env('Mailgun_Forward_Address', false);
     $result = $mgClient->post('routes', ['priority' => 2000, 'expression' => 'match_recipient("' . $recipient . '")', 'action' => ['forward("' . $defaultAddress . '")', 'stop()'], 'description' => 'Ok']);
     return $result->http_response_code . ': ' . $result->http_response_body->message;
 }
开发者ID:Bogstag,项目名称:bogstag.se,代码行数:7,代码来源:EmailDropController.php

示例4: listaddmemberAction

 public function listaddmemberAction($listname, $address, $name)
 {
     $logger = $this->container->get('logger');
     $mailgun = new Mailgun($this->private_key, $this->APIURL, "v3", true);
     $listAddress = $listname . $this->GROUPEMAIL;
     $checkresult = $mailgun->get("lists", array('address' => '' . $listAddress));
     $decodedresult = json_decode(json_encode($checkresult), true);
     $count = $decodedresult['http_response_body']['total_count'];
     $logger->info('Testing adding member ' . $address);
     if ($decodedresult['http_response_code'] != 200) {
         $result = $this->listcreateAction($listname, ' the list ' . $listname, $address, $name);
         $logger->info('adding list ' . $address . ' ' . serialize($result));
     }
     $result = $mailgun->post("lists/{$listAddress}/members", array('address' => '' . $address, 'name' => '' . $name, 'subscribed' => true, 'upsert' => true));
     $logger->info('adding member ' . $address . ' ' . serialize($result));
     return $this->JsonResponse($result);
 }
开发者ID:austinpapp,项目名称:push-notifications-temp,代码行数:17,代码来源:MailgunApi.php

示例5: postNews

 /**
  * @param Request $request
  *
  * @throws \Mailgun\Messages\Exceptions\MissingRequiredMIMEParameters
  */
 public function postNews(Request $request)
 {
     $mg = new Mailgun(config('services.mailgun.secret'));
     $mgValidate = new Mailgun(config('services.mailgun.public'));
     $domain = config('services.mailgun.domain');
     $mailingList = 'novidades@phpmga.net';
     $secretPassphrase = env('APP_KEY');
     $recipientAddress = $request->get('email');
     $result = $mgValidate->get('address/validate', array('address' => $recipientAddress));
     if ($result->http_response_body->is_valid == true) {
         # Next, instantiate an OptInHandler object from the SDK.
         $optInHandler = $mg->OptInHandler();
         # Next, generate a hash.
         $generatedHash = $optInHandler->generateHash($mailingList, $secretPassphrase, $recipientAddress);
         # Now, let's send a confirmation to the recipient with our link.
         $mg->sendMessage($domain, array('from' => config('services.mailgun.contact'), 'to' => $recipientAddress, 'subject' => 'Por favor confirme sua inscrição!', 'html' => "<html><body>Olá,<br><br>Você solicitou a inclusão de seu email em nossa lista\n                                                   {$mailingList}. Por favor <a\n                                                  href=\"http://{$domain}/email/confirm?hash={$generatedHash}\">\n                                                  confirme</a> sua inscrição.<br><br>Obrigado!</body></html>"));
         # Finally, let's add the subscriber to a Mailing List, as unsubscribed, so we can track non-conversions.
         if ($mg->post("lists/{$mailingList}/members", array('address' => $recipientAddress, 'subscribed' => 'no', 'upsert' => 'yes'))) {
             return Response::make(['success' => true]);
         }
     }
     return Response::make(['success' => false]);
 }
开发者ID:phpmga,项目名称:website,代码行数:28,代码来源:EmailController.php

示例6: add_array_list_members

 /**
  * Add an array of emails to a Mailgun list
  *
  * @since 1.0.0
  *
  * @param string $list_address The address of the list to add addresses to.
  * @param array $array Array of emails to be JSON encoded.
  */
 public function add_array_list_members($list_address, $array)
 {
     if (is_array($array)) {
         $json = json_encode($array);
         try {
             // Instantiate the client.
             $mg_client = new Mailgun(MAILGUN_API_KEY);
             // Issue the call to the client.
             $result = $mg_client->post("lists/{$list_address}/members.json", array('members' => $address, 'upsert' => 'true'));
             return $result;
         } catch (Exception $e) {
             $this->custom_log('The following error occured when trying to add addresses to ' . $list_address . ': ' . $e->getMessage());
         }
     } else {
         $this->custom_log('Bad array input:' . print_r($json));
     }
 }
开发者ID:mckernanin,项目名称:oa-tools,代码行数:25,代码来源:class-oa-tools-mailgun.php

示例7: Mailgun

<?php 
require 'mailgun-php/vendor/autoload.php';
use Mailgun\Mailgun;
// mailgun credentials
$mg = new Mailgun("key-a643dfc4abedf6a8ee23c2173b5a2c96");
// $mgValidate = new Mailgun('pub-key-example');
$domain = "thehealthbits.com";
$mailingList = "subscribers@" . $domain;
$secretPassphrase = 'a_secret_passphrase';
$recipientName = $_POST['fields_fname'];
$recipientAddress = $_POST['fields_email'];
# Let's validate the customer's email address, using Mailgun's validation endpoint.
// $result = $mgValidate->get('address/validate', array('address' => $recipientAddress));
// if($result->http_response_body->is_valid == true){
# Next, instantiate an OptInHandler object from the SDK.
$optInHandler = $mg->OptInHandler();
# Next, generate a hash.
$generatedHash = $optInHandler->generateHash($mailingList, $secretPassphrase, $recipientAddress);
# Now, let's send a confirmation to the recipient with our link.
// $mg->sendMessage($domain, array('from'    => 'bob@example.com',
//                                 'to'      => $recipientAddress,
//                                 'subject' => 'Please Confirm!',
//                                 'html'    => "<html><body>Hello,<br><br>You have requested to be subscribed
//                                               to the mailing list $mailingList. Please <a
//                                               href=\"http://yourdomain.com/subscribe.php?hash=$generatedHash\">
//                                               confirm</a> your subscription.<br><br>Thank you!</body></html>"));
# Finally, let's add the subscriber to a Mailing List, as unsubscribed, so we can track non-conversions.
$mg->post("lists/{$mailingList}/members", array('address' => $recipientAddress, 'name' => $recipientName, 'subscribed' => true, 'upsert' => 'yes'));
// }
header("Location:/subscribe-thank-you/");
die;
开发者ID:agentfitz,项目名称:thb,代码行数:31,代码来源:signup_action.php

示例8: Mailgun

 function mg_add_subscriber($email_id, $name = NULL)
 {
     $key = get_instance()->config->item('mailgun_key');
     $mg = new Mailgun($key);
     $list_address = get_instance()->config->item('newsletter_address');
     # Issue the call to the client.
     $result = $mg->post("lists/{$list_address}/members", array('address' => $email_id, 'name' => $name, 'subscribed' => 'yes', 'upsert' => 'true'));
 }
开发者ID:jatin-github,项目名称:psycho_store,代码行数:8,代码来源:mailgun_helper.php

示例9: subscribe

 /**
  *
  * Perform the subscription
  *
  */
 private function subscribe()
 {
     // First, instantiate the SDK with the API credentials, domain, and required parameters.
     $mg = new Mailgun($this->privateKey);
     $mgValidate = new Mailgun($this->publicKey);
     // Let's validate the customer's email address, using Mailgun's validation endpoint.
     $result = $mgValidate->get('address/validate', array('address' => $this->recipientAddress));
     if ($result->http_response_body->is_valid == true) {
         // Now, let's send a confirmation to the recipient with our link.
         $mg->sendMessage($this->domain, ['from' => $this->mailingList, 'to' => $this->recipientAddress, 'subject' => 'Thank You!', 'html' => "<html><body>Hello,<br><br>Thank you for subscribing to the " . $this->mailingList . " mailing list. We will let you know about any updates.</body></html>"]);
         // Finally, let's add the subscriber to a Mailing List.
         $mg->post("lists/" . $this->mailingList . "/members", ['address' => $this->recipientAddress, 'subscribed' => 'yes', 'upsert' => 'yes']);
     }
 }
开发者ID:adamtester,项目名称:subscribe-to-mailgun,代码行数:19,代码来源:index.php

示例10: transportMailMailgun

 /**
  * Transport mail message with mailgun services
  *
  * @param $to
  * @param $subj
  * @param $body
  * @param $hash
  * @param $intro
  * @param $options
  *
  * @return bool
  */
 public static function transportMailMailgun($to, $subj, $body, $hash, $intro, $options)
 {
     // @TODO make sure that from and reply-to addresses are correctly set in headers
     if (!is_array($to)) {
         $to = explode(',', $to);
     }
     $signature = Util::lavnn('signature', $options, 'team');
     $language = Util::lavnn('language', $options, 'en');
     $sender = Util::lavnn('sender', $options, 0);
     $config = Config::getInstance();
     # Instantiate the client.
     $mgClient = new Mailgun($config->get('mailgun.apiKey'));
     $domain = $config->get('mailgun.domain');
     $msgBuilder = $mgClient->MessageBuilder();
     $from = $config->get('mailgun.from');
     if ($signature != 'team' && $sender > 0) {
         $userModel = new User();
         if ($userModel->load($sender)->isValid()) {
             $from = $userModel->get('fname') . ' ' . $userModel->get('lname') . ' <' . $userModel->get('email') . '>';
         }
     }
     $msgBuilder->setFromAddress($from);
     foreach ($to as $recipient) {
         $msgBuilder->addToRecipient(trim($recipient));
     }
     $msgBuilder->setSubject($subj);
     $msgBuilder->setTextBody(self::prepareTextMail($subj, $body, $hash, $intro, $signature, $language, $sender));
     $msgBuilder->setHtmlBody(self::prepareHtmlMail($subj, $body, $hash, $intro, $signature, $language, $sender));
     $result = $mgClient->post("{$domain}/messages", $msgBuilder->getMessage(), $msgBuilder->getFiles());
     return $result->http_response_code == 200;
 }
开发者ID:barcodex,项目名称:kasha-mail,代码行数:43,代码来源:MailUtil.php

示例11: array

<?php

use Mail\Mail;
require '../vendor/autoload.php';
$loader = new Twig_Loader_Filesystem('../views/twig');
$twig = new Twig_Environment($loader, array('cache' => false));
$mail = new Mail();
if (isset($_POST['from'])) {
    $mail->writeMail($_POST);
    $mail->sendMail();
}
echo $twig->render("form.twig");
use Mailgun\Mailgun;
# Instantiate the client.
$mgClient = new Mailgun('key-3c246e362731a7f0458f67ea00e31479');
# Issue the call to the client.
$result = $mgClient->post("routes", array('priority' => 0, 'expression' => 'match_recipient(".*@sandboxbcb41bc62f6d485e9e43ef8edb592f7b.mailgun.org")', 'action' => array('forward("nino@skvorc.org")', 'stop()'), 'description' => 'Sample route'));
开发者ID:Rayac,项目名称:mail,代码行数:17,代码来源:index.php

示例12: send

 public function send(MessageViewModel $message)
 {
     $domain = $this->options->getDomain();
     return $this->mg->post("{$domain}/messages", $message->getMessage(), $message->getFiles());
 }
开发者ID:ebittleman,项目名称:mailgun-zf2,代码行数:5,代码来源:MailgunSender.php


注:本文中的Mailgun\Mailgun::post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。