Skip to content
Snippets Groups Projects
Select Git revision
  • c61daa81392c15b41fdc0cfb81b76a4f4adf68a8
  • master default protected
  • intros
  • live_sources
  • bootstrap4
  • modules
6 results

template_helper.py

Blame
  • Forked from Video AG Infrastruktur / website
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    mail.js 990 B
    import nodemailer from "nodemailer";
    
    const transporter = nodemailer.createTransport({
    	host: process.env.MAIL_HOST,
    	port: parseInt(process.env.MAIL_PORT),
    	auth: {
    		user: process.env.MAIL_USER,
    		pass: process.env.MAIL_PASSWORD
    	},
    	secure: process.env.MAIL_TLS === "true",
    	authMethod: process.env.MAIL_AUTH_METHOD
    });
    
    /**
     * @param {Object} mailOptions
     * @param {string} mailOptions.to The email address to send the email to
     * @param {string} mailOptions.subject The subject of the email
     * @param {string} mailOptions.text The content of the email
     * @param {boolean} [mailOptions.html=false] `true` if `text` is HTML, `false` if `text` is plain text
     * @returns 
     */
    export async function sendMail({to, subject, text, html=false}) {
    	const content = html ? {html: text} : {text};
    	return transporter.sendMail({
    		subject,
    		to,
    		from: {
    			address: process.env.MAIL_FROM_ADDRESS,
    			name: process.env.MAIL_FROM_NAME
    		},
    		replyTo: process.env.MAIL_REPLY_TO,
    		...content
    	});
    }