I am trying to send mail by using nodemailer's mail api from express js server on microsoft azure. It's getting success in local machine but not on azure server(remote). Any idea?
var mail = require("nodemailer").mail;
mail({from: "from#gmail.com", // sender address
to: "to#gmail.com", // list of receivers
subject: "subject", // Subject line
text: "text", // plaintext body
html: "<b>helloworld</b>" // html body
});
thanks,
av
Just in case someone else meet the same problem.
I had the same problem about running Nodemailer in Azure Website. Finally I found the problem was that I forgot put Nodemailer as a dependency in package.json. Then azure did not know it had to install Nodemailer for the hosted server.
Add "nodemailer" : "*" at the end of dependency list in package.json. Don't forget to add a "," after the last line before you add "nodemailer".
Hope it helps.
Please do changes in iisnode.yml file to call newer nodejs version as follows-
nodeProcessCommandLine: "D:\Program Files (x86)\nodejs\8.5.0\node.exe"
Related
I am working on angular (frontend) and node ( backend). I want to send an email using sendgrid , With excel file as attachment. I followed the app as reference demo app .Instead of downloading the excel, I want the same file to be sent as email attachment.
Note : In the backend I use nodejs, I am not sure how to pass the file with API to node.js, I can send email in nodejs code.
Can someone help me on this?
You can make an http post request in the node api back-end and pass the file. Do post using headers as Multipart form request.
Multipart form request helps you to make the node js api pass the excel sheet generated on the front end.
In your email service add the http service call to the backend. And make the service pass the file in it
Check this link out for more details
https://blog.jscrambler.com/implementing-file-upload-using-node-and-angular/
So I have my app created using create-react-app in Azure, but need to add ability to send mail once a Form is submitted. I know this cannot be done in my react app, but being away from backend work for a bit, I was trying to search for a tutorial or something online that could guide me and setting up some sort of node.js with sendgrid so that this UI can now process sending emails with my forms. Can any of you recommend some direction, tutorials, etc... to assist with this as I am not seeing things on the Sendgrid website for this.
Thanks for the help.
Check the library sendgrid-nodejs repo, which includes detailed examples for Node.js:
const sgMail = require('#sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: 'test#example.com',
from: 'test#example.com',
subject: 'Sending with SendGrid is Fun',
text: 'and easy to do anywhere, even with Node.js',
html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);
For more complex use cases, please see USE_CASES.md.
I am using NodeMailer for mail service. I have to get an email address from a field in client side and send that value to app.js where my nodemailer code resides.
client side
ngOnInit() {
this.forgotForm = this.formBuilder.group({
email: this.email,
});
}
sendmail() {
}
app.js, Nodemailer code (I have to get email id for to address here)
let mailOptions = {
from: 'xyz#gmail.com',
to: '',
subject: 'Test Mailer',
text: 'I am testing Nodemailer to send email.',
};
You Should Consider Looking/ Learning Angular and then going into forms . and then into http modules which will help you post data to services
This is a gist not the actual answer
There are a lots of ways to get this done , using normal inputs and getting data from that input using button control or using Forms[the best approach] as you might have other details to send as well.
There are two kind of froms in Angular Template Driven or Reactive Forms.
After getting the details in your form you will need to post it to a Rest service i am guessing. For that you will need to look at Angular Http Client Module
Please look at those links for more detailed Info on them.
You need to use services in angular in order to do this. in terminal set the path to a folder where you want create service, and then use the command ng generate service <service_name> . This will create a file service_name.service.ts. You can refer https://codecraft.tv/courses/angular/http/overview/ or https://angular.io/tutorial/toh-pt4 for more details.
You can use APIs along with http methods get, post, put, delete etc. to complete your task.
In respective component.ts file create a variable email like:
email =string;
In the html file bind the input field with ngModel as:
[(ngModel)]="email"
Then make a function in service.ts that accepts email as arguments
endMail(email) {
//make api call using http method(say post)
// supply email
let url = <APIURL>
return http.post(url, {email: email});
}
Again in component.ts import this service and instantiate in constructor and use a method to call service
I am using Node Mailer to send email from node application. Now this mail contains attachment which is a share point link and looks something like below -
{ // use URL as an attachment
filename: 'license.txt',
path: 'https://raw.github.com/nodemailer/nodemailer/master/LICENSE'
}
The problem is when I send this mail it gives me 403 forbidden error which I understand is due to the share point link needs authentication. My question is how do I pass the authentication and which type of authentication node mailer would accept for fetching the share point document as an attachment.
I have been trying to create an Google order Schema markup for our orders. However, the html template that I generate works when I run it using the google App Script Test
Code.gs file in Google App script
function testSchemas() {
var htmlBody = HtmlService.createHtmlOutputFromFile('template_html').getContent();
MailApp.sendEmail({
// to: Session.getActiveUser().getEmail(),
to:'MY GMAIL EMAIL',
subject: 'Test Actions in the Inbox - ' + new Date(),
htmlBody: htmlBody,
});
}
But when I use the same html template in nodemailer and run the nodemailer with the same gmail credentials using the Gmail Service, I do not find the
"View order" section.
I am aware that to: and from: addresses need to be same for testing schemas and I have the same to and from address.
My nodemailer config looks something like:
var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "GMAIL EMAIL",
pass: "PASSWORD"
}
});
smtpTransport.sendMail(mailOptions,function(err,response){console.log('Done');});
Google says your email must be SPF/DKIM enabled in order to stop phishing attacks but when I am using the Gmail service, it must not be the case.
Can anybody tell me what might be the reason for this and the workaround of how could I test it using node mailer before I raise a request to whitelist my IpP to Google.
Also, can we make Google orders to appear as Google card in Google Now.