Skip to content

Commit 23da4be

Browse files
fix: err invalid protcol while sending file in mail
1 parent 299648b commit 23da4be

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

apps/OpenSignServer/cloud/parsefunction/sendMailGmailProvider.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const refreshAccessToken = async refreshToken => {
2727

2828
// Function to create a raw email message
2929
const makeEmail = async (to, from, subject, html, url, pdfName) => {
30+
const protocol = new URL(process.env.SERVER_URL);
3031
const htmlContent = html;
3132
const boundary = 'boundary_' + Date.now().toString(16);
3233
let str;
@@ -35,7 +36,7 @@ const makeEmail = async (to, from, subject, html, url, pdfName) => {
3536
let Pdf = fs.createWriteStream('test.pdf');
3637
const writeToLocalDisk = () => {
3738
return new Promise((resolve, reject) => {
38-
if (useLocal !== 'true') {
39+
if (useLocal !== 'true' && protocol.hostname !== 'localhost') {
3940
https.get(url, async function (response) {
4041
response.pipe(Pdf);
4142
response.on('end', () => resolve('success'));

apps/OpenSignServer/cloud/parsefunction/sendMailv3.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { smtpenable, smtpsecure, updateMailCount, useLocal } from '../../Utils.j
77
import sendMailGmailProvider from './sendMailGmailProvider.js';
88
import { createTransport } from 'nodemailer';
99
async function sendMailProvider(req) {
10+
const protocol = new URL(process.env.SERVER_URL);
1011
try {
1112
let transporterSMTP;
1213
let mailgunClient;
@@ -33,7 +34,7 @@ async function sendMailProvider(req) {
3334
let Pdf = fs.createWriteStream('test.pdf');
3435
const writeToLocalDisk = () => {
3536
return new Promise((resolve, reject) => {
36-
if (useLocal !== 'true') {
37+
if (useLocal !== 'true' && protocol.hostname !== 'localhost') {
3738
https.get(req.params.url, async function (response) {
3839
response.pipe(Pdf);
3940
response.on('end', () => resolve('success'));

0 commit comments

Comments
 (0)