本文整理匯總了PHP中Mailgun\Mailgun::put方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mailgun::put方法的具體用法?PHP Mailgun::put怎麽用?PHP Mailgun::put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mailgun\Mailgun
的用法示例。
在下文中一共展示了Mailgun::put方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: Mailgun
function mg_unsubscribe($email_id)
{
$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->put("lists/{$list_address}/members", array('address' => $email_id, 'subscribed' => 'no'));
}