nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
862 stars 146 forks source link

Omit onMailFrom #120

Open OctavianGuzu opened 5 years ago

OctavianGuzu commented 5 years ago

Hello,

I'm using smtp-server for receiving a flow of emails. Some of them don't follow the RFC, more exactly the MAIL FROM: <test@test.com> format. These will get an 501 Bad sender address syntax error.

Is it possible to omit this check so I can receive these emails as well? As from the documentation, the checks are done when "onMailFrom" is called, but if I remove the method then I get an error saying "ReferenceError: myOnMailFrom is not defined".

songth commented 3 years ago

smtp-connection.js

I think it's correct to be revised as below.

Original

        if (!/^<[^<>]*>$/.test(address)) {
            invalid = true;
        } else {
            address = address.substr(1, address.length - 2);
        }

corrected version

        if (/^<[^<>]*>$/.test(address)) {
            address = address.substr(1, address.length - 2);
        }

        if( !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(address) ) {
            invalid = true;
        }