Skip to content

Commit

Permalink
feat(gmail): allow custom from address
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSelene committed Nov 22, 2024
1 parent a0ceb29 commit 8b021d8
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export const gmailSendEmailAction = createAction({
displayName: 'Sender Name',
required: false,
}),
from: Property.ShortText({
displayName: 'Sender Email',
description:
"The address must be listed in your GMail account's settings",
required: false,
}),
attachment: Property.File({
displayName: 'Attachment',
description: 'File to attach to the email you want to send',
Expand Down Expand Up @@ -145,11 +151,14 @@ export const gmailSendEmailAction = createAction({
threadId = messages.data.messages?.[0].threadId;
}

const senderEmail = (
await google.oauth2({ version: 'v2', auth: authClient }).userinfo.get()
).data.email;
if (senderEmail && context.propsValue['sender_name']) {
mailOptions.from = `${context.propsValue['sender_name']} <${senderEmail}>`;
const senderEmail =
context.propsValue.from ||
(await google.oauth2({ version: 'v2', auth: authClient }).userinfo.get())
.data.email;
if (senderEmail) {
mailOptions.from = context.propsValue.sender_name
? `${context.propsValue['sender_name']} <${senderEmail}>`
: senderEmail;
}

if (attachment) {
Expand Down

0 comments on commit 8b021d8

Please sign in to comment.