Email not send within suitescript 2.0 - netsuite

For some reasons I can't seem to receive an email from my suitescript.
Here's my code.
define(["N/email"], function(email) {
function afterSubmit(scriptContext) {
var newOrder = scriptContext.newRecord.id;
email.send({
author: 17874,
recipients: "sam172#gmail.com",
subject: "mail from netsuite",
body: "test body email order id: " + newOrder
});
}
return {
afterSubmit: afterSubmit
};
});
This email will send when a sales order is created.
My order is send through Webservice API and every time an order is send to Netsuite, it will trigger this script to send me an email when the sales order get created.
I've been testing by place multiple order, but never receive any email. There's no error on the netsuite server error log.
What could be the problem here? thanks

You are in a Sandbox Account, Sandbox emails can only be sent to the user testing the script.

Related

Docusign nodejs envelopes api returns exports {}

I'm running the following code in my nodejs server
// Create the recipient view, the Signing Ceremony
let viewRequest: RecipientViewRequest = {
returnUrl: "http://localhost:3000/fund/123?state=123",
authenticationMethod: "none",
email: "my_email",
userName: "Ryan",
clientUserId: "my client user id",
pingFrequency: "600",
pingUrl: "http://localhost:3000"
};
// Call the CreateRecipientView API
// Exceptions will be caught by the calling function
const dsApiClient = new ApiClient();
dsApiClient.setBasePath("https://account-d.docusign.com");
const api = new EnvelopesApi(dsApiClient);
const results = await api.createRecipientView(
"1234",
"5678",
{ recipientViewRequest: viewRequest }
);
and it keeps giving me the output of exports {} no errors or anything. this is pretty painful to debug. has anyone else ran into a similar problem? and how did you fix it?
When you use embedded signing you must set the clientUserId.
But, the clientUserId has to be set when the envelope is created, or when the recipient is added to an a draft envelope and must match the value you later pass in a request for a recipient View.
You cannot make a request for recipient view for an envelope that was created via the web app, unless your code modified that envelope to set the clientUserId for the recipient you want.

DocuSign using TemplateID remote signing and Webhook notification for AutoResponded (non-existing signer email)

I'm not getting any webhook notifications for bad email addresses that respond back with unknown mail recipients. I do get a notification email for this but no webhook notification.
envelope code setup
{
var envelopeDefinition = new EnvelopeDefinition()
{
EmailSubject = request.EmailSubject,
EventNotification = new EventNotification()
{
RequireAcknowledgment = "true",
Url = config.Value.EnvelopeEventUrl,
EnvelopeEvents = new List<EnvelopeEvent>
{
//new EnvelopeEvent("Delivered"),
new EnvelopeEvent(EnvelopeEventStatusCode: "Voided"),
new EnvelopeEvent(EnvelopeEventStatusCode: "Declined"),
new EnvelopeEvent(EnvelopeEventStatusCode: "Completed", true.ToString()),
},
RecipientEvents = new List<RecipientEvent>
{
new RecipientEvent(RecipientEventStatusCode:"AuthenticationFailed"),
new RecipientEvent(RecipientEventStatusCode:"AutoResponded"),
new RecipientEvent(RecipientEventStatusCode:"Delivered"),
new RecipientEvent(RecipientEventStatusCode:"Declined"),
new RecipientEvent(RecipientEventStatusCode:"Completed"),
}
},
TemplateId = request.TemplateId,
Status = "Sent",
EmailSettings = new EmailSettings(ReplyEmailAddressOverride: "Reply#xxxxFinance.com.au", ReplyEmailNameOverride: "John Smith"),
};
Sadly this DocuSign link is broken
See Using Webhooks to Track Envelope Status for details
Also I can't login to support using my DocuSign Demo account (Sandbox account), not sure why, so can't log a support ticket!
So, first of - the link is not broken. Not sure what you meant by that.
Second, the issue here may be that sometimes remote servers do not respond back very quickly to let you know an email bounced.
You could try a different strategy where you look for the positive message (that the status of the recipient changed to indicate the email message was sent succsefully) and if you don't get that within say, 5 min - you assume it bounced (but that's on you, sometimes it is just delayed a lot).
See, you subscribed to five different recipient events. The one called "Delivered" is the positive (or opposite) of "AutoResponded" (which may also mean that the person had their Out-Of-Office message on). So, by checking if it was delivered, you can tell when the message got there safely, but not when it bounced for sure.

Create and Return Firebase Email Verification Link inside a Firebase Cloud Function

I have a firebase cloud function trigger an send a Welcome email when someone signs up. I would like to include my email verification link in that same email to reduce the amount of emails users get upon signup and improve the onboarding experience (rather than sending two separate emails).
exports.sendWelcomeEmail = functions.auth.user().onCreate(event => {
// Get user that signed up
const user = event.data; // The Firebase user.
// get the email of the user that signed up
const email = user.email; // The email of the user.
// Create email verification link
var emailVerificationLink = user.createEmailVerificationLink() // NEED HELP HERE: ideally, I would like to create/call a function to create an email verification link for the user here
// send email
mailgun.messages().send({
from: 'support#example.com',
to: email,
subject: 'Welcome & Get Started',
text: 'Welcome! Here are some resources to help you get started, but first verify your email: ' + emailVerificationLink + '!',
html: // some nice formatted version of the text above
}, function (error, response) {
console.log("Email response");
console.log(response);
console.log("Email error");
console.log(error);
});
})
I have carefully looked through the documentation on custom email handlers, but it doesn't seem like they return the email verification link, so I do not see how to use that approach for my purposes here (although I hope I'm wrong).
Is there a way to create the email verification link inside a Firebase Cloud Function in such a way that I could then use resulting link as I please (like in my Welcome email)?
There is no public API to get the OOB verification code, or the link that contains that code.
But you can implement this yourself with a few steps:
Generate your own verification code, that you store somewhere securely (e.g. in a protected section of your Firebase Database).
Embed that code in your message in a link.
Create a Cloud Function at that link.
Handle the request, check the verification code in the database
Set emailVerified to true.
This isn't all that much different from what Firebase Authentication does when you call sendEmailVerification().

Nodemailer with ZOHO mail

I'm trying to setup ZOHO mail with Nodemailer. The mail is configured correctly and I'm using following code to send the mail:
var transporter = nodemailer.createTransport({
host: 'smtp.zoho.eu',
port: 465,
secure: true, //ssl
auth: {
user:'info#myaddress.be',
pass:'supersecretpassword'
}
});
sendMail = function(req,res) {
var data = req.body;
transporter.sendMail({
from: data.contactEmail,
to: 'info#myaddress.be',
subject: data.contactSubject,
text: data.contactMsg
});
res.json(data);
};
I contacted official support but no response so far. Maybe someone here has experience with it. The problem is that when using these settings I get a message that relaying is disallowed for the address in variable 'data.contactEmail'. When I change the from e-mail also to info#myaddress.be I do receive the e-mail but of course I do not know who sent it and can't reply to it.
Anyone who knows how to make the 'from' address work with unknown addresses? Like john#gmail.com ?
Solution :
You should make an email account for your server : bot#myaddress.be
When you are going to relay the mail craft a custom MAILBODY containing the subject and message
var MAILBODY ='\n[suject]:\n'+data.contactSubject+'\n\n[msg]:\n'+data.contactMsg;
So you will be sending the original contactEmail as the subject of the mail and using the mail's text (body) to se the message subject and the message content.
transporter.sendMail({
from: 'bot#myaddress.be',
to: 'info#myaddress.be',
subject: data.contactEmail,
text: MAILBODY
});
Reason of Solution :
Example bot account will be able of sending the email to yourself with all the details you really need. (because you control that email account / your domain)
The credentials you are providing are for your OWN account and you are trying to send an email FROM an unknown account. This might only be possible if you had the credentials for the unknown account (given that they have allowed open access to other clients/apps).
You simply can not send an email on behalf of an account you do not have credentials for.

Retrieving fields of email with logic apps / azure function

I have a use case where an HTML form is filled with user data and an email is sent to their email address, CC'ed to a logic app.
The logic app would receive this email and read only the values after name: and email form fields so that I can pass them along to another function.
How would one do this in a logic apps or within an Azure function?
This blog has great information on using Azure Functions from Logic Apps.
Assuming you have the logic app set up to receive emails, you then add a step to process emails in an Azure Function App sending the email content as an input.
Sample Input payload to nodejs webhook trigger:
{
"email": {
"emailBody": "Body×​​",
"text": "Hello from Logic Apps"
}
}
Note: "Bodyx" is the dynamic content representing the email body that was received in an earlier step.
Corresponding index.js in the function app:
module.exports = function (context, data) {
var email = data.email;
// You can now do processing on the emailBody
context.log('email body', email.emailBody);
context.res = {
body: {
greeting: 'Hello !' + email.text
}
};
context.done();
};
Hope this helps!

Resources