mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-09-04 16:58:05 +02:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
609608f78e |
@@ -35,7 +35,8 @@ const makeEmail = async (
|
|||||||
bcc,
|
bcc,
|
||||||
filename,
|
filename,
|
||||||
certificatePath,
|
certificatePath,
|
||||||
replyto
|
replyto,
|
||||||
|
testPdf
|
||||||
) => {
|
) => {
|
||||||
const publicUrl = new URL(process.env.SERVER_URL);
|
const publicUrl = new URL(process.env.SERVER_URL);
|
||||||
const htmlContent = html;
|
const htmlContent = html;
|
||||||
@@ -46,7 +47,7 @@ const makeEmail = async (
|
|||||||
let str;
|
let str;
|
||||||
if (url) {
|
if (url) {
|
||||||
let attachments;
|
let attachments;
|
||||||
let Pdf = fs.createWriteStream('test.pdf');
|
let Pdf = fs.createWriteStream(testPdf);
|
||||||
const writeToLocalDisk = () => {
|
const writeToLocalDisk = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const isSecure =
|
const isSecure =
|
||||||
@@ -161,6 +162,8 @@ export default async function sendMailGmailProvider(_extRes, template) {
|
|||||||
// Construct email message
|
// Construct email message
|
||||||
const from = sender || _extRes.Email || 'me';
|
const from = sender || _extRes.Email || 'me';
|
||||||
const to = receiver;
|
const to = receiver;
|
||||||
|
const randomNumber = Math.floor(Math.random() * 5000);
|
||||||
|
const testPdf = `test_${randomNumber}.pdf`;
|
||||||
const email = await makeEmail(
|
const email = await makeEmail(
|
||||||
to,
|
to,
|
||||||
from,
|
from,
|
||||||
@@ -171,7 +174,8 @@ export default async function sendMailGmailProvider(_extRes, template) {
|
|||||||
bcc,
|
bcc,
|
||||||
filename,
|
filename,
|
||||||
certificatePath,
|
certificatePath,
|
||||||
replyto
|
replyto,
|
||||||
|
testPdf
|
||||||
);
|
);
|
||||||
// Update Gmail client with new access token
|
// Update Gmail client with new access token
|
||||||
const newGmail = createGmailClient(access_token);
|
const newGmail = createGmailClient(access_token);
|
||||||
@@ -189,6 +193,13 @@ export default async function sendMailGmailProvider(_extRes, template) {
|
|||||||
console.log('Err in unlink certificate sendmailgmail provider');
|
console.log('Err in unlink certificate sendmailgmail provider');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fs.existsSync(testPdf)) {
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(testPdf);
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err in unlink pdf sendmailv3');
|
||||||
|
}
|
||||||
|
}
|
||||||
return { code: 200, message: 'Email sent successfully' };
|
return { code: 200, message: 'Email sent successfully' };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error sending email:', error);
|
console.error('Error sending email:', error);
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ async function sendMailProvider(req, plan, monthchange) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (req.params.url) {
|
if (req.params.url) {
|
||||||
let Pdf = fs.createWriteStream('test.pdf');
|
const randomNumber = Math.floor(Math.random() * 5000);
|
||||||
|
const testPdf = `test_${randomNumber}.pdf`;
|
||||||
|
let Pdf = fs.createWriteStream(testPdf);
|
||||||
const writeToLocalDisk = () => {
|
const writeToLocalDisk = () => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const isSecure =
|
const isSecure =
|
||||||
@@ -129,6 +131,13 @@ async function sendMailProvider(req, plan, monthchange) {
|
|||||||
console.log('Err in unlink certificate sendmailv3');
|
console.log('Err in unlink certificate sendmailv3');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fs.existsSync(testPdf)) {
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(testPdf);
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err in unlink pdf sendmailv3');
|
||||||
|
}
|
||||||
|
}
|
||||||
return { status: 'success' };
|
return { status: 'success' };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -146,6 +155,13 @@ async function sendMailProvider(req, plan, monthchange) {
|
|||||||
console.log('Err in unlink certificate sendmailv3');
|
console.log('Err in unlink certificate sendmailv3');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fs.existsSync(testPdf)) {
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(testPdf);
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err in unlink pdf sendmailv3');
|
||||||
|
}
|
||||||
|
}
|
||||||
return { status: 'success' };
|
return { status: 'success' };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -156,6 +172,13 @@ async function sendMailProvider(req, plan, monthchange) {
|
|||||||
console.log('Err in unlink certificate sendmailv3');
|
console.log('Err in unlink certificate sendmailv3');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fs.existsSync(testPdf)) {
|
||||||
|
try {
|
||||||
|
fs.unlinkSync(testPdf);
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Err in unlink pdf sendmailv3');
|
||||||
|
}
|
||||||
|
}
|
||||||
return { status: 'error' };
|
return { status: 'error' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user