How can i send email multiple time from jenkins pipeline - email

I have a jenkins pipeline in which i have defined stages, I want to send email after specific stage number and at the end of the job.
For Example : Suppose i have a job in which i have 8 steps. I want that job will send success email after 6th stage if all 6 stages have successfully run. And again the same pipeline will send status after all stages are executed.
I know how to send email at the last(after all stages completed) but i am not able to find any solution for how to send email in between stages.

You can do this with emailext:
Here is a sample:
pipeline {
agent {
label 'slave'
}
stages {
stage('First Mail') {
steps {
emailext to: 'send.mail#email',
from: 'send.from#email',
subject: "First Mail",
body: "Here is the content of the first Mail"
}
}
stage('Second Mail') {
steps {
emailext to: 'send.mail#email',
from: 'send.from#email',
subject: "Secont Mail",
body: "Here is the content of the second Mail"
}
}
}
}
If you want to send the mails based on the result of the job, you can take a look at this answered question: Send email on jenkins pipeline failure

Related

Firebase email trigger not working on gmail

I use firebase email trigger and trying to send an email to my gmail account and another account which is not gmail. I received email only on my another account, gmail doesn't work.
Here is my code.
db.collection('mail').add({
to: 'user#gmail.com',
cc: 'user#example.com',
message: {
subject: 'Welcome',
html: 'Hello',
},
})
Here is my mail collection response
Response looks fine.
I received email only on user#example.com account.
I'd be very grateful if some could help me.
Thanks in advance.
The Trigger Email extension for Firebase makes no distinction in how it handles gmail destinations vs other email addresses, so it is very unlikely that this difference happens in the sending of the email.
More likely the email is getting caught in either the spam filter of gmail, or in another spam filter along the way to gmail. I recommend checking your gmail spam box first.
I have changed from email and it works now.
Thanks
Be sure to check in the firebase/firestore itself,
the errors will show in the document itself:
[![error code in firestore][1]][1]
as mentioned, do check your trigger-email settings, that they are linked to the correct collection:
[![collection linked to trigger-email][2]][2]
// Firestore data converter
export const contactFormConvertor = {
toFirestore: (contactform: ContactformDTO) => {
return {
to: <INSERT email you wish to receive the mail on>,
name: contactform._name,
from: <INSERT email you use to send the mail from>,
replyTo: contactform._email,
message: {text: contactform._message + '\n\nkind regards, ' + contactform._name,
subject: contactform._subject}
};
},
fromFirestore: (snapshot: { data: (arg0: any) => any; }, options: any) => {
const data = snapshot.data(options);
return new ContactformDTO(data.name, data.email, data.subject, data.message);
}
};```
[1]: https://i.stack.imgur.com/08cIQ.png
[2]: https://i.stack.imgur.com/m4Sod.png

In Gmail, using Google Apps Script, is it possible to forward the TRANSLATED emails which I receive to another email address?

I receive many emails in Japanese everyday (I am living in Japan). Gmail automatically detect that the email is written in Japanese, so that one can click the "translate" button and get it translated. I would like to forward the translated email to another email address (or to a mailing list). It is easy to set up the mail forwarding, but when I do, only the original message (in Japanese) is forwarded. So my question is:
Is it possible, using Google Apps Scripts script (or any another tool), to forward the TRANSLATED emails which I receive to another email address?
I am a very beginner with Google tools, so any help is appreciated!
You can use the built-in LanguageApp service to translate text.
GmailApp.getInboxThreads().forEach((thread) => {
thread
.getMessages()
.filter((message) => {
return (
message.getFrom().toLowerCase().indexOf("sender#example.com") !== -1
);
})
.forEach((message) => {
if (MailApp.getRemainingDailyQuota() > 1) {
message.forward("email#example.com", {
htmlBody: LanguageApp.translate(message.getBody(), "jp", "en"),
});
}
});
});
To complete #Amit's answer:
You can build your filter based on the sender using the .getFrom() method on a message instance. Here you can find an example.
GmailApp.getInboxThreads().forEach( thread => {
thread.getMessages().forEach( message => {
if (message.getFrom() === "email2#example.com" {
message.forward("email#example.com", { htmlBody: LanguageApp.translate(message.getBody(), "jp", "en") }
}
});
});
Reference
GmailApp

Facebook Messenger Bot 'sender action typing on' in node.js

How do I make my chatbot to indicate that it is typing?
The following code doesn't work at all...
function sendQuickReply(recipientId){
var messageData = {
recipient: {
id: recipientId
},
sender_action: "typing_on",
message:{
text:"$%",
quick_replies:[
{
content_type:"text",
title:"%^",
payload:"morning",
image_url:"http://emojip
You can't send a message with a text/image/payload and a sender action.
You need to write 2 functions (or requests). And the request with the sender action needs to have only the recipient id and the sender action in parameters.
https://developers.facebook.com/docs/messenger-platform/send-messages/sender-actions

Google Form - One form submission sends two (unique) emails

Please excuse my possibly "lame" question here. I have searched everywhere and have not been able to find a solution.
Google forms -
I have one form that collects two email addresses.
I need to have each email entered into the form receive a "unique" response when the form is submitted.
Below is an example of the code I've been "trying" to make work. (Where I only get the latter email to send)
I thank you in advance for your time.
Oliver
// this would be the first email sent to e.values[3] - the first email on the form
function formSubmitReply(e) {
var userEmail = e.values[3];
MailApp.sendEmail(
userEmail,
"Help Desk Ticket1",
"Thanks for submitting your issue. \n\nWe'll start " +
"working on it as soon as possible. \n\nHelp Desk",
{name:"Help Desk"}
);
}
// this would be the second email sent to e.values[4] - the second email on the form
function formSubmitReply(e) {
var userEmail = e.values[4];
MailApp.sendEmail(
userEmail,
"Help Desk Ticket - FYI form is sent",
"The form a has been submitted. \n\nWe need to start " +
"working on it as soon as possible. \n\nThe Reger Group",
{name:"The Reger Group"}
);
}
This is a blind shot (haven't tested), but here is my guess: you are creating the same function twice, thus the second replaces the first one. Functions are unique, if you can only have one function as callback of the form submission, you should adapt it to do everything you need within the one function call.
Here's what you could do:
// Sends distinct messages for each recipient
function formSubmitReply(e) {
// First mail recipient and message
MailApp.sendEmail(
e.values[3],
"Help Desk Ticket1",
"Thanks for submitting your issue. \n\nWe'll start " +
"working on it as soon as possible. \n\nHelp Desk",
{name:"Help Desk"}
);
// Second mail recipient and message
MailApp.sendEmail(
e.values[4],
"Help Desk Ticket - FYI form is sent",
"The form a has been submitted. \n\nWe need to start " +
"working on it as soon as possible. \n\nThe Reger Group",
{name:"The Reger Group"}
);
}

Send mail for multiple user and the each recipents have only his email address not the others

I am new bie for send grid. I have checked this url for two emails "https://sendgrid.com/api/mail.send.js..." and got the mail successfully in both emails.
The mail received by the users from the above URL have both email address in "TO" field like
For ex. User Test To: test#example.com;test2#example.com. and For User test2 To: test#example.com;test2#example.com.
As per my requirement i want to send mail for multiple user and the each recipents have only his email address not the others.
For ex. User Test To: test#example.com and For User test2 To: test2#example.com.
Can this scenario is possible with send grid.
Thanks
You can send the same email to multiple recipients by using the SendGrid SMTP API's to parameter.
To do this you'll set an X-SMTPAPI: header in your message, this header will include the JSON to communicate with SendGrid's SMTP API. The header will look as such:
X-SMTPAPI: { "to": [ "test#example.com", "test2#example.com" ] }
Each recipient will receive a unique email, addressed only to them.
Be aware: you'll still need to set a To: header for the message to send, however you can set this to yourself or one of the recipients (and then exclude them from the JSON list).
Send grid being a standard SMTP server will respond as if you are sending email from gmail, yahoo or outlook.
The scenario is not possible that I am aware of. I have only incorporated it into 2 applications, so I am certain there are better experts.
As an alternative you could test using the blind copy, The problem with that is would need a main address in the To field, which may not fill your requirement.
Send email on Azure Mobile Service /NodeJS
var sendgrid = new SendGrid('KEY');
sendgrid.send({
to: toEMail, // ["email1#mail.com", "email2#mail.com",...]
from: fromEMail,
subject: subject,
text: body
}, function (success, message) {
console.log("send mail: " + subject);
// If the email failed to send, log it as an error so we can investigate
if (!success) {
console.error(message);
}
});
possible on Sendgrid. You can use the normal bcc on sendgrid via personalization, but we dont like it because the To: is always required. So my solution is sendgrid transactional email. This will send 1 email to multiple users (using sendgrid / php / laravel ):
$email = new \SendGrid\Mail\Mail();
$email->setFrom("sender#mail.com", "Sender Name");
$email->setSubject("Your subject");
$email->addTo(
"email.1#mail.com",
"User One",
[],
0
);
$email->addTo(
"email.2#mail.com",
"User Two",
[],
1
);
$email->addTo(
"email.3#mail.com",
"User Three",
[],
2
);
$email->addContent("text/plain", "your body");
$email->addContent("text/html", "<strong>your body</body>");
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
try {
$response = $sendgrid->send($email);
return response()->json($response, 200);
} catch (Exception $e) {
return response()->json($e->getMessage(), 400);
}