kaisellgren / mailer

Compose and send emails from Dart. Supports file attachments, HTML emails and multiple transport methods.
MIT License
166 stars 86 forks source link

Email not sended. #240

Closed nothingknowaboutme12 closed 7 months ago

nothingknowaboutme12 commented 7 months ago

Mailer 6.0.1 is unable to send the email. I just returned the message that the email was sent but it did not send the email. Kindly fix this issue please.

close2 commented 7 months ago

Hi @nothingknowaboutme12

Please enable debugging output and post more information:

    Logger.root.level = Level.ALL;
    Logger.root.onRecord.listen((LogRecord rec) {
      print('${rec.level.name}: ${rec.time}: ${rec.message}');
    });

Please don't take this the wrong way, but your bug report is useless. What provider are you using, have you tried another provider; is this a new problem?

If this library wasn't able to send any mails, there would be a lot more feedback and bug reports, so there must be something special with your setup.

Personally I am pretty sure, that the library is working fine, but your provider is swallowing your message.

sherrylin728 commented 7 months ago

The two problems I encountered are as follows:

1.Using the xxx@gmail.com account, I found from the logger that an Application-specific password is required, but I don't know where to input it.

I/flutter (12475): FINE: 2024-02-06 15:45:02.127210: > 
I/flutter (12475): FINE: 2024-02-06 15:45:02.253800: < 220 smtp.gmail.com ESMTP b6-20020aa78706000000b006e050644092sm1166760pfo.55 - gsmtp
I/flutter (12475): FINE: 2024-02-06 15:45:02.257674: > EHLO localhost
I/flutter (12475): FINE: 2024-02-06 15:45:02.397247: < 250 smtp.gmail.com at your service, [218.35.166.52]
I/flutter (12475): < 250 SIZE 35882577
I/flutter (12475): < 250 8BITMIME
I/flutter (12475): < 250 STARTTLS
I/flutter (12475): < 250 ENHANCEDSTATUSCODES
I/flutter (12475): < 250 PIPELINING
I/flutter (12475): < 250 CHUNKING
I/flutter (12475): < 250 SMTPUTF8
I/flutter (12475): FINE: 2024-02-06 15:45:02.407183: > STARTTLS
I/flutter (12475): FINE: 2024-02-06 15:45:02.567512: < 220 2.0.0 Ready to start TLS
I/flutter (12475): FINE: 2024-02-06 15:45:02.633205: > EHLO localhost
I/flutter (12475): FINE: 2024-02-06 15:45:02.768253: < 250 smtp.gmail.com at your service, [218.35.166.52]
I/flutter (12475): < 250 SIZE 35882577
I/flutter (12475): < 250 8BITMIME
I/flutter (12475): < 250 AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH
I/flutter (12475): < 250 ENHANCEDSTATUSCODES
I/flutter (12475): < 250 PIPELINING
I/flutter (12475): < 250 CHUNKING
I/flutter (12475): < 250 SMTPUTF8
I/flutter (12475): FINE: 2024-02-06 15:45:02.768977: > AUTH LOGIN
I/flutter (12475): FINE: 2024-02-06 15:45:02.945381: < 334 VXNlcm5hbWU6
I/flutter (12475): FINE: 2024-02-06 15:45:02.946001: > c2hlcnJ5MDQyNjAwQGdtYWlsLmNvbQ==
I/flutter (12475): FINE: 2024-02-06 15:45:03.104128: < 334 UGFzc3dvcmQ6
I/flutter (12475): FINE: 2024-02-06 15:45:03.104440: > bWFnaWMwNDI2MDA=
I/flutter (12475): FINE: 2024-02-06 15:45:03.338010: < 534 5.7.9 Application-specific password required. For more information, go to
I/flutter (12475): < 534 5.7.9  https://support.google.com/mail/?p=InvalidSecondFactor b6-20020aa78706000000b006e050644092sm1166760pfo.55 - gsmtp
I/flutter (12475): Message not sent.
  1. Our mail server is: email-smtp.us-east-1.amazonaws.com. After setting it up via SmtpServer and executing, the following error occurs.

    final smtpServer = SmtpServer(
                'email-smtp.us-east-1.amazonaws.com',
                port:xxxx,
                ignoreBadCertificate: false,
                ssl: true,
                username: username,
                password: password
            );
    
            // Create our message.
            final message = Message()
              ..from = Address("xxx@xxx.xxx", 'xxxxxxx')
              ..recipients.add('xxxx@xxxx.xxx')
              ..subject = 'Test Dart Mailer library :: 😀 :: ${DateTime.now()}'
              ..text = 'This is the plain text.\nThis is line 2 of the text part.'
              ..html = "<h1>Test</h1>\n<p>Hey! Here's some HTML content</p>";
 /flutter (12475): FINER: 2024-02-06 15:58:38.018938: Connecting to email-smtp.us-east-1.amazonaws.com at port xxxx.
E/flutter (12475): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: HandshakeException: Handshake error in client (OS Error: 
E/flutter (12475):  WRONG_VERSION_NUMBER(tls_record.cc:231))
E/flutter (12475): #0      _SecureFilterImpl._handshake (dart:io-patch/secure_socket_patch.dart:99:46)
E/flutter (12475): #1      _SecureFilterImpl.handshake (dart:io-patch/secure_socket_patch.dart:143:25)
E/flutter (12475): #2      _RawSecureSocket._secureHandshake (dart:io/secure_socket.dart:920:54)
E/flutter (12475): #3      _RawSecureSocket._tryFilter (dart:io/secure_socket.dart:1049:19)
E/flutter (12475): <asynchronous suspension>
close2 commented 7 months ago

to create an app specific password:

Try the amazonaws smtp server without ssl. Usually smtp servers don't use SSL connections, but switch to a secure connection with STARTTLS.

The error indicates, that you are trying to connect with a secure connection and that the library can't establish this connection.

I will close this issue for now. If you think, that there is still a bug, please reopen.