$this->recipientAddress = $params['recipientAddress']; } else { die('No recipientAddress Set'); } if ($error) { die('Config not properly set'); } } /** * * 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']); } } } $v = new App(); $v->boot();
<?php $autoload = (require __DIR__ . '/vendor/autoload.php'); $autoload->add("", __DIR__ . "/app"); $app = new App(array('debug' => TRUE, 'session.test' => TRUE)); $app->boot(); $app['mp.user.boot_commands'](); $app['odm.boot_commands'](); $app['console']->run();