import { isArray, merge } from 'lodash'
import { createTransport, Transporter } from 'nodemailer'
import { join } from 'path'
+import { root } from '@shared/core-utils'
import { EmailPayload } from '@shared/models'
import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model'
-import { isTestInstance, root } from '../helpers/core-utils'
+import { isTestOrDevInstance } from '../helpers/core-utils'
import { bunyanLogger, logger } from '../helpers/logger'
import { CONFIG, isEmailEnabled } from '../initializers/config'
import { WEBSERVER } from '../initializers/constants'
this.initialized = true
if (!isEmailEnabled()) {
- if (!isTestInstance()) {
+ if (!isTestOrDevInstance()) {
logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!')
}
async sendMail (options: EmailPayload) {
if (!isEmailEnabled()) {
- throw new Error('Cannot send mail because SMTP is not configured.')
+ logger.info('Cannot send mail because SMTP is not configured.')
+ return
}
const fromDisplayName = options.from
const email = new Email({
send: true,
+ htmlToText: {
+ selectors: [
+ { selector: 'img', format: 'skip' },
+ { selector: 'a', options: { hideLinkHrefIfSameAsText: true } }
+ ]
+ },
message: {
from: `"${fromDisplayName}" <${CONFIG.SMTP.FROM_ADDRESS}>`
},
}
}
- // overriden/new variables given for a specific template in the payload
+ // overridden/new variables given for a specific template in the payload
const sendOptions = merge(baseOptions, options)
await email.send(sendOptions)