Files
automatisch/packages/backend/src/apps/smtp/auth/verify-credentials.ts
2022-10-23 20:12:48 +02:00

23 lines
549 B
TypeScript

import { IGlobalVariable } from '@automatisch/types';
import nodemailer, { TransportOptions } from 'nodemailer';
const verifyCredentials = async ($: IGlobalVariable) => {
const client = nodemailer.createTransport({
host: $.auth.data.host,
port: $.auth.data.port,
secure: $.auth.data.useTls,
auth: {
user: $.auth.data.username,
pass: $.auth.data.password,
},
} as TransportOptions);
await client.verify();
await $.auth.set({
screenName: $.auth.data.username,
});
};
export default verifyCredentials;