本文整理匯總了PHP中Mailgun\Mailgun::OptInHandler方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mailgun::OptInHandler方法的具體用法?PHP Mailgun::OptInHandler怎麽用?PHP Mailgun::OptInHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mailgun\Mailgun
的用法示例。
在下文中一共展示了Mailgun::OptInHandler方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getConfirm
/**
* @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ão foi possível confirmar sua inscrição, tente novamente mais tarde.");
}
示例2: define
<?php
require Kohana::find_file('vendor/mailgun1.7.2', 'autoload');
use Mailgun\Mailgun;
$data_mailgun = $this->db->get('mailgun_config')->result_array(false);
if (!empty($data_mailgun[0])) {
define('MAILGUN_KEY', $data_mailgun[0]['mailgun_key']);
define('MAILGUN_PUBKEY', $data_mailgun[0]['mailgun_pubkey']);
define('MAIL_FROM', $data_mailgun[0]['mailgun_from']);
define('MAILGUN_DOMAIN', $data_mailgun[0]['mailgun_domain']);
}
define('MAILGUN_LIST', 'customer@sandbox54bdc93fa0844c69a4c4eb16e9cefecf.mailgun.org');
define('MAILGUN_SECRET', 'webtos.websolutions.vn');
$mailgun = new Mailgun(MAILGUN_KEY);
$mailgunValidate = new Mailgun(MAILGUN_PUBKEY);
$mailgunOptIn = $mailgun->OptInHandler();
示例3: 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;
示例4: optInHandler
/**
* @return \Mailgun\Lists\OptInHandler
*/
public function optInHandler()
{
return $this->mailgun->OptInHandler();
}