zone-eu / zone-mta

📤 Modern outbound MTA cross platform and extendable server application
European Union Public License 1.2
606 stars 96 forks source link

CRAM-MD5 support #429

Closed railty closed 4 weeks ago

railty commented 4 weeks ago

I am using a pretty standard nodemailer

const nodemailerCramMd5 = require('nodemailer-cram-md5'); let transporter = nodemailer.createTransport({ host: '127.0.0.1', port: 587, secure: false, // Port 587 does not use SSL, set to false auth: { type: 'custom', method: 'CRAM-MD5', user: 'alice@abc.com', pass: 'your-email-password' }, tls: { ciphers: 'SSLv3', rejectUnauthorized: false }, customAuth: { 'CRAM-MD5': nodemailerCramMd5 } });

let mailOptions = {
    from: '"Alice <alice@abc.com>',
    to: 'bob@xyz.com',
    subject: 'Test Email', // Email subject
    text: 'Hello! This is a test email sent using Node.js', // Plain text body
    html: '<p>Hello! This is a <b>test email</b> sent using Node.js</p>' // HTML body
};

// Send the email
try {
    let info = await transporter.sendMail(mailOptions);
    console.log('Email sent successfully:', info.messageId);
} catch (error) {
    console.error('Error sending email:', error);
}

and get the error:

response: '504 Error: Unrecognized authentication type', responseCode: 504, command: 'AUTH CRAM-MD5'

I managed to trace to the node_modules/smtp-server/smtp-connection.js, and found _server.options.authMethods have only LOGIN and PLAIN auth type.

Do I need another plugin to support CRAM-MD5, or if I need write one, where can I start?

louis-lau commented 4 weeks ago

Is there a reason you need CRAM-MD5? Instead if just relying on TLS?

andris9 commented 4 weeks ago

No plans to support CRAM protocols. These are horrible and outdated protocols. Even using it usually raises suspicions that the person is trying something shady 🤔

railty commented 4 weeks ago

Thanks for the explanition, I am pretty new to these and didn't realize that CRAM is outdated.

railty commented 4 weeks ago

btw, there seems quite a bit of code in smtp-server/sasl.js support CRAM-MD5, but since you said it is outdated, I didn't bother too much