Reputation: 171
I have created a firebase function which sends an email once triggered. The issue is that when I try deploying it, it gives me an error
Functions deploy had errors with the following functions: sendMail(us-central1)
To try redeploying those functions, run: firebase deploy --only "functions:sendMail"
To continue deploying other features (such as database), run: firebase deploy --except functions
Error: Functions did not deploy properly.
here is my current code:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const nodemailer = require('nodemailer');
const cors = require('cors')({origin: true});
admin.initializeApp();
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'yourgmailaccpassword'
}
});
exports.sendMail = functions.https.onRequest((req, res) => {
cors(req, res, () => {
const dest = req.query.dest;
const mailOptions = {
from: 'Your Account Name <[email protected]>',
to: dest,
subject: 'I\'M A PICKLE!!!',
html: `<p style="font-size: 16px;">Pickle Riiiiiiiiiiiiiiiick!!</p>`
};
return transporter.sendMail(mailOptions, (erro, info) => {
if(erro){
return res.send(erro.toString());
}
return res.send('Sended');
});
});
});
how can I resolve this?
Upvotes: 0
Views: 200
Reputation: 4163
The cause of this issue can be hard to debug, many users have resolved this by changing their CLI version, others simply require a redeploy.
firebase deploy --only "functions:sendMail"
firebase-tools@latest
[email protected]
to the previous major versionUpvotes: 0