OptInHandler() public method

public OptInHandler ( ) : OptInHandler
return Mailgun\Lists\OptInHandler
Example #1
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.");
 }
Example #2
0
File: init.php Project: vobinh/PHP
<?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', '*****@*****.**');
define('MAILGUN_SECRET', 'webtos.websolutions.vn');
$mailgun = new Mailgun(MAILGUN_KEY);
$mailgunValidate = new Mailgun(MAILGUN_PUBKEY);
$mailgunOptIn = $mailgun->OptInHandler();
Example #3
0
<?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'    => '*****@*****.**',
//                                 '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;
Example #4
0
 /**
  * @return \Mailgun\Lists\OptInHandler
  */
 public function optInHandler()
 {
     return $this->mailgun->OptInHandler();
 }