gmail-node-mailer
Advanced tools
Comparing version 1.8.6 to 1.8.61
@@ -52,2 +52,2 @@ /** | ||
import { ISendEmailParams, ISendEmailFunctionResponse } from '../types'; | ||
export declare function sendEmailFunction(gmailClient: gmail_v1.Gmail, { senderEmail, recipientEmail, subject, message, attachments }: ISendEmailParams): Promise<ISendEmailFunctionResponse>; | ||
export declare function sendEmailFunction(gmailClient: gmail_v1.Gmail, params: ISendEmailParams): Promise<ISendEmailFunctionResponse>; |
@@ -65,4 +65,5 @@ "use strict"; | ||
const types_1 = require("../types"); | ||
function sendEmailFunction(gmailClient_1, _a) { | ||
return __awaiter(this, arguments, void 0, function* (gmailClient, { senderEmail, recipientEmail, subject, message, attachments }) { | ||
function sendEmailFunction(gmailClient, params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { senderEmail, senderName, recipientEmail, subject, message, attachments } = params; | ||
try { | ||
@@ -72,4 +73,5 @@ const { encodedContent: encodedSubject } = (0, encodeEmailContent_1.encodeEmailContent)({ content: subject || '', type: types_1.EncodingType.Subject }); | ||
let boundary = "----=_NextPart_" + Math.random().toString(36).substr(2, 9); | ||
let mimeMessage = `From: ${senderEmail}\r\nTo: ${recipientEmail}\r\nSubject: ${encodedSubject}\r\n`; | ||
// Define the top level MIME type based on whether there are attachments | ||
// Conditionally add senderName to the From header | ||
let mimeMessage = `From: ${senderName ? `"${senderName}" <${senderEmail}>` : senderEmail}\r\nTo: ${recipientEmail}\r\nSubject: ${encodedSubject}\r\n`; | ||
// Define the top level MIME type | ||
mimeMessage += `Content-Type: ${attachments && attachments.length > 0 ? "multipart/mixed" : "multipart/alternative"}; boundary=${boundary}\r\n\r\n`; | ||
@@ -76,0 +78,0 @@ // Add the main message part (HTML or plain text) |
@@ -29,2 +29,3 @@ import { google } from 'googleapis'; | ||
senderEmail?: string; | ||
senderName?: string; | ||
subject?: string; | ||
@@ -31,0 +32,0 @@ message: string; |
{ | ||
"name": "gmail-node-mailer", | ||
"version": "1.8.6", | ||
"version": "1.8.61", | ||
"description": "gmail-node-mailer is a Node.js library for easy email sending via the Gmail API, featuring quick setup, HTML/plain text support, dynamic configuration for streamlined email integration, and now with support for attachments.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -56,3 +56,4 @@ /** | ||
export async function sendEmailFunction(gmailClient: gmail_v1.Gmail, { senderEmail, recipientEmail, subject, message, attachments }: ISendEmailParams): Promise<ISendEmailFunctionResponse> { | ||
export async function sendEmailFunction(gmailClient: gmail_v1.Gmail, params: ISendEmailParams): Promise<ISendEmailFunctionResponse> { | ||
const { senderEmail, senderName, recipientEmail, subject, message, attachments } = params; | ||
try { | ||
@@ -63,5 +64,6 @@ const { encodedContent: encodedSubject } = encodeEmailContent({ content: subject || '', type: EncodingType.Subject }); | ||
let boundary = "----=_NextPart_" + Math.random().toString(36).substr(2, 9); | ||
let mimeMessage = `From: ${senderEmail}\r\nTo: ${recipientEmail}\r\nSubject: ${encodedSubject}\r\n`; | ||
// Conditionally add senderName to the From header | ||
let mimeMessage = `From: ${senderName ? `"${senderName}" <${senderEmail}>` : senderEmail}\r\nTo: ${recipientEmail}\r\nSubject: ${encodedSubject}\r\n`; | ||
// Define the top level MIME type based on whether there are attachments | ||
// Define the top level MIME type | ||
mimeMessage += `Content-Type: ${attachments && attachments.length > 0 ? "multipart/mixed" : "multipart/alternative"}; boundary=${boundary}\r\n\r\n`; | ||
@@ -116,2 +118,2 @@ | ||
} | ||
} | ||
} |
@@ -41,2 +41,3 @@ import { google } from 'googleapis'; | ||
senderEmail?: string; | ||
senderName?: string; // Optional sender display name | ||
subject?: string; | ||
@@ -43,0 +44,0 @@ message: string; |
112657
1731