I am trying to send a reset password link through the sendgrid email. My email template is like this
<html><head>
<title>Reset Password</title>
</style>
<!--user entered Head Start--><link href="https://fonts.googleapis.com/css?family=Fira+Sans+Condensed&display=swap" rel="stylesheet"><style>
body {font-family: 'Fira Sans Condensed', sans-serif;}
</style>
</head>
<body style="background-color:#9E9E9E;">
<div style="padding:20px;border:1px solid #9E9E9E;background-color:white">
<h1>Reset Password</h1>
<hr>
<p>Click the button below to reset your password.</p>
RESET PASSWORD
<p>If you did not make this
request, please ignore this email.</p>
</div>
<div>
<p style="padding:20px;border:1px solid #9E9E9E;">Send by Information Systems.</p>
<div>
</body></html>
And back-end code is like this
const msg = {
to: 'someone#gmail.com',
from: 'sender#example.org',
templateId: 'xxxx',
dynamic_template_data: {
subject: 'Testing Templates',
},
};
await sgMail.send(msg);
How do I pass a URL address to the template and attach that to the href attribute in the <a> tag?
I think you are very close. Doing something like below should work
RESET PASSWORD
and then in your dynamic_template_data do
...
dynamic_template_data: {
subject: 'Testing Templates',
url: 'https://somelink.com..'
}
...
Related
I am trying to write a php app to sign users into BigCommerce when they log into my website. I can't see anything in the API docs on logging in or SSO. Does anyone have a pointer to some docs on this?
well, I've tried with a trial store this issue and the only way that I found is using a hidden iframe and a simple javascript. This worked for me, See the example:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<title>Login BC</title>
<style type="text/css">
input[type="text"],input[type="password"],input[type="submit"],button{
display: block;
padding:4px 6px;
margin: 12px 8px;
border: 1px solid #eee;
}
input[type="text"],input[type="password"]{
width:200px;
}
input[type="submit"],button{
cursor:pointer;
}
#ifr{
display: none;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var redirect={
data:{
url:'http://yourstore.mybigcommerce.com/login.php?action=check_login',
redirect:'http://yourstore.mybigcommerce.com/account.php?action=account_details',
login:'customerlogin',
pass:'customerpassword'},
form:function(){
var f='<form method="post" id="bc" action="'+redirect.data.url+'">'+
'<input type="text" name="login_email" value="'+redirect.data.login+'"/>'+
'<input type="password" name="login_pass" value="'+redirect.data.pass+'" />'+
'<input type="submit" value="Login" />'+
'</form>';
$('iframe#ifr').contents().find('html > body').html(f);
$('#ifr').contents().find('form#bc').submit();
},
events:function(){
$('#send').on('click',function(){
redirect.form();
setTimeout(function(){
$('section').append('<button id="goto">Go To Bigcommerce</button>');
},1500);
});
$(document).on('click','#goto',function(){
window.location = redirect.data.redirect;
});
}
};
redirect.events();
})
</script>
</head>
<body>
<div class="content">
<section>
<button id="send">Auto Login</button>
</section>
</div>
<iframe id="ifr"></iframe>
</body>
</html>
Anyone still looking to do something similar can now take a look at the JWT-based Customer Login API (https://developer.bigcommerce.com/api/v2/#customer-login-api).
Combined with the customer read and write endpoints of the API, it should allow an external application to create and login a customer from an external application.
What's the easiest way to get a visitors city, state and country based on their IP address and fill it into a form field?
For example I have a basic form field:
<input type="text" name="city" value="*AUTOFILL CITY HERE*" />
Instead of having them fill this information in I'd like to just hide the form field and have it autofill based on their IP.
I found a solution for you which is in the form of html, javascript and jquery.
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<h3>Client side IP geolocation using ipinfo.io</h3>
<hr/>
<div id="ip"></div>
<div id="address"></div>
<hr/>Full response: <pre id="details"></pre>
<input type="text" value="" id="city" />
<script type="text/javascript">
$.get("https://ipinfo.io", function (response) {
$("#ip").html("IP: " + response.ip);
$("#address").html("Location: " + response.city + ", " + response.region);
$("#details").html(JSON.stringify(response, null, 4));
$("#city").html(response.city);
document.getElementById('city').value = response.city;
}, "jsonp");
</script>
</body>
</html>
City is filled in automatically, and using the same process you can display the State, as well as the Country, of your visitors.
I will preface this by saying my background is Graphic Design (been doing JavaScript for a few years).Ok, I've been looking and looking for a simple tutorial on how to create a basic form with a a controller, that sends the form info in the body of an email.
This is what I have in my GSP:
<g:form name="batchform" url="[action:'forminfo', controller:'onboardingform'] />
<label>Application Group or Area</label>
<g:textField name="apparea01" type="text" placeholder="Place Holder Text Field 1" value='${params.apparea01}' />
<label>Department Name</label>
<g:textField name="deptname02" type="text" placeholder="Place Holder Text Field 2" value='${params.deptname02}' />
<input type="submit" value="Submit Form" id="FormButton" >
<g:form>
And the controller is where I get confused:
package .com
import util.Environment
import MailTools
import MetricsLogger
class OnboardingformController {
String apparea01,
String deptname02
static constraints = {
apparea01 blank: false, nullable: false
deptname02 blank: false, nullable: false
}
def index() {
render (view:'onboardingform.gsp')
}
sendMail {
to 'me#email.com'
cc params.mail
subject 'I am the form test in the subjectline'
body 'i am the body of the form. I should have vars here that display the user input from form fields'
}
}
I do not currently have a DOMAIN set up since there is no DB attached to this site. I just need to shove those Field Inputs into the Email body. I realize this maybe a very basic operation that escapes me (my background is Fine Arts, not Computer Science).
The MailTools is configured already to a default mailbox. The form needs to be send to another email address.
The MetricsLogger captures user info upon landing on the page.
Thanks in advance. This knowledge will open my eyes in my quest to be an Artist / Programmer :)
Ok, I came up with this controller in
grails-app/controllers/test/OnboardingformController.groovy:
package test
class OnboardingformController {
def index() {
render( view: 'onboardingForm.gsp' )
}
def formSubmission( String apparea01, String deptname02, String email ) {
println "Send Mail from $email to me#email.com with apparea01=$apparea01 and deptname02=$deptname02"
/*
// Commented out for now so I don't have to set up mail ;-)
sendMail {
to 'me#email.com'
cc params.mail
subject 'I am the form test in the subjectline'
body 'i am the body of the form. I should have vars here that display the user input from form fields'
}
*/
redirect( action:'index' )
}
}
And this GSP grails-app/onboardingform/onboardingform.gsp:
<!DOCTYPE html>
<html>
<head>
<meta name="layout" content="main"/>
<title>Onboarding</title>
</head>
<body>
<g:form action="formSubmission">
<p>
<label>Application Group or Area</label>
<g:textField name="apparea01" type="text" placeholder="Place Holder Text Field 1" value='${params.apparea01}' />
</p>
<p>
<label>Department Name</label>
<g:textField name="deptname02" type="text" placeholder="Place Holder Text Field 2" value='${params.deptname02}' />
</p>
<p>
<label>Email</label>
<g:textField name="email" type="text" placeholder="Place Holder Text Field 3" value='${params.email}' />
</p>
<p>
<input type="submit" value="Submit Form" id="FormButton" >
</p>
</g:form>
</body>
</html>
Which when the form is filled in, should print out the values you entered (to the console) and redirect to the form. Let me know if anything doesn't make sense :-)
If you need validation (without a domain object), you can use a Command Object. This changes the controller to:
package test
class OnboardingformController {
def index() {
render( view: 'onboardingForm.gsp' )
}
def formSubmission( SubmissionCommandObject cmd ) {
if( !cmd.validate() ) {
render( view: 'onboardingForm.gsp', model:[ data: cmd ] )
return
}
else {
println "Send Mail from $cmd.email to me#email.com with apparea01=$cmd.apparea01 and deptname02=$cmd.deptname02"
}
redirect( action:'index' )
}
}
class SubmissionCommandObject {
String apparea01
String deptname02
String email
static constraints = {
apparea01 blank: false, nullable: false
deptname02 blank: false, nullable: false
email blank: false, email: true
}
}
And the view to:
<!DOCTYPE html>
<html>
<head>
<meta name="layout" content="main"/>
<title>Onboarding</title>
</head>
<body>
<g:hasErrors bean="${data}">
<g:renderErrors bean="${data}" as="list" />
</g:hasErrors>
<g:form action="formSubmission">
<fieldset>
<p class="prop ${hasErrors(bean:data, field:'apparea01', 'errors')}">
<label>Application Group or Area</label>
<g:textField name="apparea01" type="text" placeholder="Place Holder Text Field 1" value='${data?.apparea01}' />
</p>
<p class="prop ${hasErrors(bean:data, field:'deptname02', 'errors')}">
<label>Department Name</label>
<g:textField name="deptname02" type="text" placeholder="Place Holder Text Field 2" value='${data?.deptname02}' />
</p>
<p class="prop ${hasErrors(bean:data, field:'email', 'errors')}">
<label>Email</label>
<g:textField name="email" type="text" placeholder="Place Holder Text Field 3" value='${data?.email}' />
</p>
<p>
<input type="submit" value="Submit Form" id="FormButton" >
</p>
</fieldset>
</g:form>
</body>
</html>
Obviously, this could be prettier, but will suffice for this quick example
I need to add a button on my app, to send a suggest mail to my gmail.
I tried some methods but none of them worked.
I was trying, like this:
<section data-role="page" id="home">
<article data-role="content" style="position: fixed;text-align: center;width: 100%;height: 100%;margin:0;padding:0;overflow: hidden;" >
<!--<a id="go" href="#view-feed-custom"> <img style="max-width: 100%;" src="img/portada.jpg" alt="Logo"> </a>-->
<script>
var args = {
subject: 'Hi there',
body: 'message to suggest you',
toRecipients: 'reciver#gmail.com'
};
cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
</script>
Enviar Sugerencia 2
</article>
</section>
I now trying the both method that u show me...
<body onload="init()">
<!-- START -->
<section data-role="page" id="home">
<article data-role="content" style="position: fixed;text-align: center;width: 100%;height: 100%;margin:0;padding:0;overflow: hidden;" >
<a id="go" href="#view-feed-custom"> <img style="max-width: 100%;" src="img/portada.jpg" alt="Logo"> </a>
</article>
<script>
function send(){
var args = {
subject: 'Hi there',
body: 'message to suggest you',
toRecipients: 'miemail#gmail.com'
};
cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
}
</script>
<button onclick='send();'>Send Mail onClick</button>
<button href="mailto:email#email.com?cc=email2#email.com&bcc=email3#email.com&subject=The subject of the email&body=The body of the email">Enviar Correo href</button>
</section>
But no run/works...
Thx a lot guys for help me!
Instead of using <a> tag use <button> tag and give 'onClick=aFunction();' inside the tag attribute.
and aFunction() can be defined as-
function aFunction(){
var args = {
subject: 'Hi there',
body: 'message to suggest you',
toRecipients: 'reciver#gmail.com'
};
cordova.exec(null, null, "EmailComposer", "showEmailComposer", [args]);
}
Also, Make sure that u have added the EmailComposer.js in the www folder and .m (assuming that u are on iOS)and .h files in plugins folder.
Have you tried:
email
And you can add more parameters like this:
Send mail with cc, bcc, subject and body
This anchor will call the native mailbox of the device.
I want to send my Application invites to multiple random people in my friends list just as its done in majority of application.
For Instance
As soon as i Accept the application this pop up appears.What i cannot understand is how to get the ID's of these users ? On the Client Side ?
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title>Request Example</title>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<p>
<input type="button"
onclick="sendRequestToRecipients(); return false;"
value="Send Request to Users Directly"
/>
<input type="text" value="User ID" name="user_ids" />
</p>
<p>
<input type="button"
onclick="sendRequestViaMultiFriendSelector(); return false;"
value="Send Request to Many Users with MFS"
/>
</p>
<script>
FB.init({
appId : '423165827708510',
frictionlessRequests: true,
});
function sendRequestToRecipients() {
var user_ids = document.getElementsByName("user_ids")[0].value;
FB.ui({method: 'apprequests',
message: 'My Great Request',
to: user_ids, /// How to Fill the ID's HERE ?
}, requestCallback);
}
function sendRequestViaMultiFriendSelector() {
FB.ui({method: 'apprequests',
message: 'My Great Request'
}, requestCallback);
}
function requestCallback(response) {
// Handle callback here
}
</script>
</body>
</html>
Why would you want to send to random users?
That doesn't make any sense - surely you'd invite the people you think will like the game?!
Confusion aside, to answer your question, the 'to' parameter is either an array, or a comma seperated list of user IDs.
Here's an example of CSV, taken from the documentation:
function sendRequestToRecipients() {
FB.ui({method: 'apprequests',
message: 'My Great Request',
to: '499802820,499802852'
}, requestCallback);
}