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

send email through "gmail function" successfully, but can not get email notification from gmail... #223

Closed TONYCHOU81905 closed 9 months ago

TONYCHOU81905 commented 1 year ago

Hello!

I faced a problem that I can send email through "gmail function" successfully, but gmail will not send the notification when gmail receive the email that I sent, it just shows up in the gmail.

Does anyone face the same situation? Thanks in advance.

close2 commented 1 year ago

Sorry, I don't understand the text. Please try to rephrase.

TONYCHOU81905 commented 1 year ago

OKay~ I mean that when I use "gmail" smtp server to send email. the email will be sent successfully but without the notification from gmail app. And when I use the same "gmail" smtp server to send email in Python, the email will be sent successfully and with the notification from gmail app.

I don't know does anyone face the same situation, or just there is something that I didn't notice.

close2 commented 1 year ago

Please verify that the accounts are different. The account used for the SMTP server must not be the same account, which receives the mail. Google won't display any notifications if they are the same.

If they are different, send me 2 emails: one from dart mailer, and one from your python program. (git@3.141.email)

TONYCHOU81905 commented 1 year ago

I have sent you two email. Thanks a lot!

xTheMasters commented 9 months ago

I have the same issue and this is my function The email is sent successfully but the user never receives it if the service is from @gmail.com.

PS: this only happens if I use mailer, if I send an email from the panel offered by ionos to an email @gmail.com, the email is sent and the recipient receives it correctly.


Future<void> sendNotificationEmail(String userId) async {
  final email = 'support@themonstersapp.com';
  final password = '******';
  final server = 'smtp.ionos.com';

  final smtpServer = SmtpServer(
    server,
    username: email,
    password: password,
  );

  final message = Message()
    ..from = Address('no-reply@dmtraining.themonstersapp.com', 'DMTraining')
    ..recipients.add(auth.currentUser!.email)
    ..subject = '${S.current.securityalertfor} ${auth.currentUser!.email}'
    ..text =
        'Text';

  bool isConnected = false;
  while (!isConnected) {
    try {
      final connection = PersistentConnection(smtpServer);
      await connection.send(message);
      await connection.close();
      isConnected = true;
    } on MailerException catch (e) {
      String? error = '';

      switch (e.toString()) {
        case 'Authentication Failed (code: 535), response:\n< Authentication credentials invalid':
          error = 'Error (code: 535) try again later ';
          break;

        default:
          error;
          break;
      }

    }
  }
}
close2 commented 9 months ago

@xTheMasters I am not 100% sure I what you mean with "if the service is from @gmail.com". Do you mean, that you can't send mails to any @gmail.com address?

If this is the case, please "forward" me 2 mails, one sent using the mailer library, one sent using ionos, so that I can compare them. Please make sure, that you send me "originals" (including headers,...). (christian@loitsch.com)

close2 commented 9 months ago

@xTheMasters I've responded to your mails.

The problem I found was missing SPF DNS entries, which probably increased the chance of mails being blocked.

close2 commented 9 months ago

@TONYCHOU81905 Did we fix your issues?

I am pretty confident, that the problems mentioned here are not bugs in the mailer library.

If you (or other users of this library) still have problems either reopen this issue, or contact me directly (christian@loitsch.com)

TONYCHOU81905 commented 9 months ago

Hi~@close2

Actually, I have no idea why this problem happens. But I thought maybe it's because of the encoding I changed the name of the Address from Chinese to English, and then I can receive notifications from gmail.

Thank you for working with me to solve the problem:)