X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Femailer.ts;h=cbe384061355d8626029c89f27330b6e5cca80c2;hb=4759fedc6112cdb0b68b8550677c05a3b1ed62bd;hp=f384a254e017d6912a71e8063ce2c25c19aa8512;hpb=d3e56c0c4b307c99e83fbafb7f2c5884cbc20055;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index f384a254e..cbe384061 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts @@ -296,9 +296,9 @@ class Emailer { return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) } - addForgetPasswordEmailJob (to: string, resetPasswordUrl: string) { + addPasswordResetEmailJob (to: string, resetPasswordUrl: string) { const text = `Hi dear user,\n\n` + - `It seems you forgot your password on ${CONFIG.WEBSERVER.HOST}! ` + + `A reset password procedure for your account ${to} has been requested on ${CONFIG.WEBSERVER.HOST} ` + `Please follow this link to reset it: ${resetPasswordUrl}\n\n` + `If you are not the person who initiated this request, please ignore this email.\n\n` + `Cheers,\n` + @@ -361,7 +361,8 @@ class Emailer { 'PeerTube.' const emailPayload: EmailPayload = { - from: fromEmail, + fromDisplayName: fromEmail, + replyTo: fromEmail, to: [ CONFIG.ADMIN.EMAIL ], subject: '[PeerTube] Contact form submitted', text @@ -370,16 +371,21 @@ class Emailer { return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) } - sendMail (to: string[], subject: string, text: string, from?: string) { + sendMail (options: EmailPayload) { if (!Emailer.isEnabled()) { throw new Error('Cannot send mail because SMTP is not configured.') } + const fromDisplayName = options.fromDisplayName + ? options.fromDisplayName + : CONFIG.WEBSERVER.HOST + return this.transporter.sendMail({ - from: from || CONFIG.SMTP.FROM_ADDRESS, - to: to.join(','), - subject, - text + from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`, + replyTo: options.replyTo, + to: options.to.join(','), + subject: options.subject, + text: options.text }) }