Last active
August 6, 2017 05:21
-
-
Save ShuvoHabib/f0ec6a0233bc9ec7b3fa916bfaa5323f to your computer and use it in GitHub Desktop.
MailGun Subscription
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mailgunURL; | |
mailgunURL = window.location.protocol + "//" + window.location.hostname + '/ajax/mailgun.php'; | |
$('#mailgun').on('submit', function (e) { | |
$(this).attr("disabled", true); | |
var dataString = $(".newsletter-content form").serialize() | |
$.ajax({ | |
type: 'POST', | |
url: "subscribeform.php", | |
data: dataString, | |
success: function () { | |
$('.newsletter-content').html("<div id='message'></div>"); | |
$('#message').html("<h2 style='color: white; margin-top: 20px;'>Congratulations, You're Subscribed!</h2>") | |
.append("<p style='color: white'>We will be in touch soon.</p>"); | |
$('.newsletter-content form').hide(); | |
}, | |
error: function (data) { | |
console.log('Silent failure.'); | |
} | |
}); | |
return false; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use Mailgun\Mailgun; | |
# Instantiate the client. | |
$mgClient = new Mailgun('key-***'); | |
$listAddress = '[email protected]'; | |
# Issue the call to the client. | |
$result = $mgClient->post("lists/$listAddress/members", array( | |
'address' => $_POST['email'], | |
'subscribed' => true, | |
)); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="form-subscribe" id="mailgun" role="form" method="POST"> | |
<div class="form-group"> | |
<!--<input type="email" name="email" class="form-control" placeholder="Enter your email" required />--> | |
<input type="email" class="form-control" id="email" name="email" | |
placeholder="Enter your email" required> | |
<button type="submit" class="btn btn-blue mail-submit">Subscribe</button> | |
</div> | |
<div class="msg"></div> | |
</form> <!-- form-subscribe --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment