I am facing an issue with the emailJS library. I created a function to send a copy of a transaction to an email address using emailJS. However, the API is not receiving any response and I am not getting any output to the console.log. It seems like the function is not even being called. I am not sure what I did wrong and I think it might be a simple fix that I overlooked.
here is the config.js file which contains the user keys and function for mailer i removed all the keys and put in place what belongs there as an fyi to anyone thinking i forgot to fill in the keys
function sendEmail(name, address, city, state, zip, phone, email, amount) {
// Initialize EmailJS with your user ID
emailjs.init("public-key-here");
// Create the email parameters
var templateParams = {
name: name,
address: address,
city: city,
state: state,
zip: zip,
phone: phone,
email: email,
amount: amount
};
// Send the email using EmailJS
emailjs.send("service_ID", "template_ID, templateParams)
.then(function(response) {
console.log("Email sent successfully");
alert("Mail send success");
}, function(error) {
console.log("Email failed to send", error);
alert("Error sending mail");
});
}
And here is the send email function being called on the payment page
// Send email with transaction record and save order details to local storage
sendEmail(name, address, city, state, zip, phone, email, amount);
localStorage.setItem('orderDetails', JSON.stringify({
amount: parseFloat(amount),
name: name,
address: address,
city: city,
state: state,
zip: zip,
phone: phone,
email: email
}));
I get no output in my console.log and or alert that email was success or not. Any help please
Related
enter image description hereI just connected my website to firebase to login users but seems to me whenever a user registers on my website the information they put into my website gets scrambled the moment it enters firebase database
this is my code snippet of the js file
//save message to firebase
function saveMessage(Name, Surname, Email, Number, Country, Verpasswrd, Username, Birthday) {
var newMessageRef = messagesRef.push();
newMessageRef.set({
Name: Name,
Surname: Surname,
Birthday: Birthday,
Email: Email,
Number: Number,
Country: Country,
Gender: Gender,
Verpasswrd: Verpasswrd,
Passwrd: Passwrd,
Username: Username,
})
}`
[![firebase output result][2]][2]
I have recently migrated my site from Google Cloud to AWS EC2 and I'm using node.js.
The site is a job website and when I try to submit a file I now get the below error message.
Error: Failed to lookup view "index" in views directory "
The submission works fine on local host ( and also did when it was hosted on GCP). Please can you help me understand why this would be and how to fix it? Here is the code for the CV submission
if (req.file){
console.log("sending CV:"+req.file.path);
var CVLibrary = {
url: 'http://www.website.co.uk/cgi-bin/cvsubapi.pl',
formData:
{
title: title,
firstname: name,
lastname: lastName,
email: email,
county: city,
town: address2,
postcode: postCode,
telephone: phone,
salary: salary,
age: Age,
affiliateID: 20998,
industry: "Retail",
affiliatepassword: "coregalm",
currentjobtitle: jobCategories ,
doc: {
value: fs.createReadStream(req.file.path),
options: {
contentType: "application/msword",
filename: "cv.docx"
}
}
}
};
console.log("CV data:" + JSON.stringify(CVLibrary));
request.post(CVLibrary, function (error, response, body) {
if (error) {
console.log("CV Library request sent with error" + error + " body." + body);
//res.status(400).send(error);
} else {
//res.set('Content-Type', 'text/html');
//res.send(new Buffer(body));
console.log("request sent correctly CV Library:" + body);
//res.send(body)
}
});
res.render('learnnewskills', {
title: 'Welcome to job site', userInfo: {
title: title,
name,
firstname: name,
lastname: lastName,
email: email,
mobile: phone,
subAffiliate: listId,
dob: dob_day + '/' + dob_month + '/' + dob_year,
optindate: currentTimestamp,
street1: address1,
address2,
towncity: city,
postcode: postCode,
tickYes,
tickYes1,
ipaddress: ipaddress,
courseInterestYes:"",
specificCourseInterest:"",
costAwareYes:"",
currentJob,
list: listId,
currentTimestamp,
redcoursetickyes:"",
penaltyPoints:"",
DrivingBan:"",
Redlicence:""
}
});
});
I'm creating an Axios request function where I have a looot of parameters for the body request. Most are required, but some are not. What's the best way to handle this?
createAccount(username, first_name, last_name, email, language, client_name, client_email, website_url, street, city, code, country, language, lead_source, date_picker) {
return this.axiosInstance.post('/brands/image', {
username: username,
first_name: first_name,
last_name: last_name,
email: email,
language: language,
client_name: client_name,
client_email: client_email,
website: website,
street: street,
city: city,
code: code,
country: country,
lead_source: lead_source, // non-required
date_picker: date_picker, // // non-required
})
.catch(error => {
console.log("Error: ", error)
})
}
There are two basic approaches you can take:
Read the API documentation of the web service you are making requests to (which could be designed for humans or might be a machine readable JSON schema or similar)
Trial and error
There's no way for the client to know what the server cares about.
I want to get the user id on my newly created user so I could name my document to that uid, but it says null.
here's my code
addDriver(){
var $this = this
secondaryApp.auth().createUserWithEmailAndPassword($this.driver.email, $this.driver.password).then(function(user){
$this.$db.collection("driver").doc(user.uid)
.set({
fname: $this.driver.fname,
lname: $this.driver.lname,
contact_number: $this.driver.cnum,
license_number: $this.driver.license,
email: $this.driver.email,
password: $this.driver.password,
})
secondaryApp.auth().signOut();
$this.formHeaderStatus = $this.$db.auth().currentUser
})
},
Also, am I doing this right? coz I'm logged in as an admin? and I want to create a new user without logging myself out.
I am not entirely sure but I believe the problem lies when using the promise returned by createUserWithEmailAndPassword.
From what I have gathered it should be like this :
addDriver(){
var $this = this
secondaryApp.auth().createUserWithEmailAndPassword($this.driver.email, $this.driver.password).then(function(**data**){
$this.$db.collection("driver").doc(**data.user.uid**)
.set({
fname: $this.driver.fname,
lname: $this.driver.lname,
contact_number: $this.driver.cnum,
license_number: $this.driver.license,
email: $this.driver.email,
password: $this.driver.password,
})
secondaryApp.auth().signOut();
$this.formHeaderStatus = $this.$db.auth().currentUser
})
},
Hope it helps, if not, let me know.
But as Franck said, if you want to sign a new user up while staying logged-in, you should use the Admin-SDK in your back end or Cloud Functions
i have a test for a registration form (name, email, pw), and i'd like to have it so that it uses a randomly generated email address each time so i don't have to do any cleanup or editing of the test.
do i need helper files for this or can i do it within the test?
my snippet looks like this --
casper.then(function() {
this.echo('signing up with the follow credentials:', 'COMMENT');
this.fill('.sign_up', {
'name': 'mariah carey',
'email': 'mariahcarey#dododoodo.com',
'password': 'testtest123'
}, true);
Inside your test script you can create javascript functions in order to generate randomly the email address.
casper.then(function() {
this.echo('signing up with the follow credentials:', 'COMMENT');
this.fill('.sign_up', {
'name': 'mariah carey',
'email': generatePassword(),
'password': 'testtest123'
}, true);
}
...
function generatePassword(){
var email;
// Here code for generate email
return email;
}
You can do the same for name and password.