rustdesk / rustdesk-server-pro

Some scripts for RustDesk Server Pro are hosted here.
110 stars 53 forks source link

SMTP Problem #99

Open Apashh opened 9 months ago

Apashh commented 9 months ago

Hello,

I'm on 1.1.10-3 and my email not send.... How change smtp settings or email without access on web console ? Maybe in sqlite ?

Thanks !

rustdesk commented 9 months ago

you can not access web console?

Apashh commented 9 months ago

Access is ok ! But when it send 2FA Code via e-mail, i have no e-mail recieve.. So i would like to disable 2FA without acess to web console 😉

rustdesk commented 9 months ago

Not working for you?

image

Apashh commented 9 months ago

I upgraded from version 1.1.9 to version 1.1.10-3. I had SMTP in the old version which worked well. Today, I no longer receive anything. I would like to deactivate 2FA without entering the WEB console. Can we do this via SQLite? or another solution?

rustdesk commented 9 months ago

We did have back compatibility test for this, but maybe we missed something.

Yes, please backup all db files first, db.sqlite3 and db.sqlite3-* files first. then you can run sqlite3 db.sqlite3 with below sql. update user set info=json_remove(info, '$.email_verification') where name='test'; please change 'test' to your name.

But in the web console after you logged in, you will still see. You can tick it off and update.

rustdesk commented 9 months ago

@dignow this is what I worried most, back compatibility. FIX this ASAP. No matter what changes we do, this is the most important thing.

dignow commented 9 months ago

I'm failed to reproduce this issue.

  1. Delete current db.sqlite3.
  2. Checkout 1.1.9.
  3. Create and migrate db.
  4. Run and configure SMTP settings, and "Enable email login verification".
  5. Checkout 1.1.10-3.
  6. Migrate db.
  7. Login.

I can receive the email after Step 7.

@Apashh Which type of email did you want to send?

image

rustdesk commented 9 months ago

Another user also reported this via sales@rustdesk.com

dignow commented 9 months ago

I've tried 1.1.8 -> 1.1.10-3 and 1.1.9 -> 1.1.10-3. Sending email 2FA code works fine when login.

rustdesk commented 9 months ago

I guess they have different settings which we do not have in our test. Let's wait for their reply.

Apashh commented 9 months ago

We did have back compatibility test for this, but maybe we missed something.

Yes, please backup all db files first, db.sqlite3 and db.sqlite3-* files first. then you can run sqlite3 db.sqlite3 with below sql. update user set info=json_remove(info, '$.email_verification') where name='test'; please change 'test' to your name.

But in the web console after you logged in, you will still see. You can tick it off and update.

I made the commands and accessed the console again but 2FA did not work. In the SMTP settings, I validate the settings (I use the same on other applications), the console tells me that everything is good, I enter an email address for tester but I receive nothing (even in spam) .

dignow commented 9 months ago

@Apashh Thanks for your feedback.

What's the test result message?

1696566797823
Apashh commented 9 months ago

@Apashh Thanks for your feedback.

What's the test result message?

1696566797823

No message when click on submit and test :

image

dignow commented 9 months ago

Does ssl0.ovh.net require payment? I'm failed to register the email.

But it's strange that there's no reply. Can you try a wrong password?

https://github.com/rustdesk/rustdesk-server-pro/assets/136106582/3989d272-7d61-45d5-9990-f607f5cc86d0

Apashh commented 9 months ago

Est-ce ssl0.ovh.netqu'il faut payer ? Je n'ai pas réussi à enregistrer l'e-mail.

Mais c'est étrange qu'il n'y ait pas de réponse. Pouvez-vous essayer un mauvais mot de passe ?

ase.mp4

I have an error :

image

But if password is good, no message appear and no message recieve in inbox

dignow commented 9 months ago

Have you input the receiver email here? If empty no test email will be sent, only updates will be made.

1696908410266
Apashh commented 9 months ago

Have you input the receiver email here? If empty no test email will be sent, only updates will be made.

1696908410266

Yep the reciever its not empty :)

dignow commented 9 months ago

I'm not clear of what you said.

Do you mean the receiver email is not empty, you have set the receiver email and then click "OK"?

If so, can you please run a rust test? Sorry for the inconvenience, but I cannot find out the reason if the message is empty while the receiver email is set.

https://crates.io/crates/lettre

use lettre::message::header::ContentType;
use lettre::transport::smtp::authentication::Credentials;
use lettre::{Message, SmtpTransport, Transport};

fn main() {
    let email = Message::builder()
        .from("NoBody <nobody@domain.tld>".parse().unwrap())
        .reply_to("Yuin <yuin@domain.tld>".parse().unwrap())
        .to("Hei <hei@domain.tld>".parse().unwrap())
        .subject("Happy new year")
        .header(ContentType::TEXT_PLAIN)
        .body(String::from("Be happy!"))
        .unwrap();

    let creds = Credentials::new("smtp_username".to_owned(), "smtp_password".to_owned());

    let mailer = SmtpTransport::starttls_relay("smtp.gmail.com")
        .unwrap()
        .credentials(creds)
        .port(587)
        .build();

    match mailer.send(&email) {
        Ok(r) => println!(
            "Email sent successfully: {}, {:?}",
            r.code(),
            r.message().collect::<Vec<&str>>()
        ),
        Err(e) => panic!("Could not send email: {:?}", e),
    }
}
Apashh commented 9 months ago

I'm not clear of what you said.

Do you mean the receiver email is not empty, you have set the receiver email and then click "OK"?

If so, can you please run a rust test? Sorry for the inconvenience, but I cannot find out the reason if the message is empty while the receiver email is set.

https://crates.io/crates/lettre

use lettre::message::header::ContentType;
use lettre::transport::smtp::authentication::Credentials;
use lettre::{Message, SmtpTransport, Transport};

fn main() {
    let email = Message::builder()
        .from("NoBody <nobody@domain.tld>".parse().unwrap())
        .reply_to("Yuin <yuin@domain.tld>".parse().unwrap())
        .to("Hei <hei@domain.tld>".parse().unwrap())
        .subject("Happy new year")
        .header(ContentType::TEXT_PLAIN)
        .body(String::from("Be happy!"))
        .unwrap();

    let creds = Credentials::new("smtp_username".to_owned(), "smtp_password".to_owned());

    let mailer = SmtpTransport::starttls_relay("smtp.gmail.com")
        .unwrap()
        .credentials(creds)
        .port(587)
        .build();

    match mailer.send(&email) {
        Ok(r) => println!(
            "Email sent successfully: {}, {:?}",
            r.code(),
            r.message().collect::<Vec<&str>>()
        ),
        Err(e) => panic!("Could not send email: {:?}", e),
    }
}

Yep I have set the reciever and click on OK but nothing ... How run rust test ?

dignow commented 9 months ago

What OS do you use? Can you run my executable file?

I've attached my files here. Please run in the terminal.

If you use linux or macos, please run chmod +x simple_test_<linux|macos> first.

1696941584609

simple_mail_test.zip

This test app uses native-tls.

The test app in https://github.com/rustdesk/rustdesk-server-pro/issues/99#issuecomment-1775326168 uses tokio1-rustls-tls.

Apashh commented 9 months ago

What OS do you use? Can you run my executable file?

I've attached my files here. Please run in the terminal.

If you use linux or macos, please run chmod +x simple_test_<linux|macos> first.

1696941584609

simple_mail_test.zip

Hello, i have test it and error : image

How add option starttls or ssl option with port 587 or 465 ?

Apashh commented 9 months ago

My command :

./simple_test_linux -f address@domain.com -p Password -P 25/587/465 -s ssl0.ovh.net -t address_to@domain.com -u address@domain.com

dignow commented 9 months ago

Add -S will set starttls to be true.

The port is set by -P.

./simple_test_linux -S -P 587 ...
Apashh commented 9 months ago

Email recieve perfectly with same option of web console

image

dignow commented 9 months ago

Thanks. I need to double check the code.

dignow commented 9 months ago

Have you restarted the server, except for the upgrade?

Can you please try restart the server?

I find a problem that the same email configuration may not trigger the send actions (if initialization fails).

Apashh commented 9 months ago

hbbr and hbbs restarted, smtp test and same, no mail, no message on webconsole...

rustdesk commented 9 months ago

Thanks @Apashh

dignow commented 9 months ago

Can you see that the update operation was successful?

1697102562686
dignow commented 9 months ago

@Apashh Can you please try again this test on your machine? Thanks.

simple_test_linux_2.zip

Use https://github.com/rustdesk/rustdesk-server-pro/issues/99#issuecomment-1775326168 instead.

Apashh commented 9 months ago

@Apashh Can you please try again this test on your machine? Thanks.

simple_test_linux_2.zip

Test and error with same command :

thread 'main' panicked at 'Could not send email: lettre::transport::smtp::Error { kind: Network, source: Custom { kind: InvalidData, error: AlertReceived(ProtocolVersion) } }', src/main.rs:93:19 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Command : ./simple_test_linux -f address@domain.com -p Password -S -P 587-s ssl0.ovh.net -t address_to@domain.com -u address@domain.com

dignow commented 9 months ago

Could not send email: lettre::transport::smtp::Error { kind: Network, source: Custom { kind: InvalidData, error: AlertReceived(ProtocolVersion) } }

This error can be handled by the server, the web console should show it.

The smtp server sometimes reports "ProtocolVersion".

Can you please try some more times to see if there're other outputs?

Apashh commented 9 months ago

Could not send email: lettre::transport::smtp::Error { kind: Network, source: Custom { kind: InvalidData, error: AlertReceived(ProtocolVersion) } }

This error can be handled by the server, the web console should show it.

The smtp server sometimes reports "ProtocolVersion".

Can you please try some more times to see if there're other outputs?

After 4 tests, its OK :

image

dignow commented 9 months ago

I find a problem that the same email configuration may not trigger the send actions (if initialization fails).

After 4 tests, its OK :

Maybe it is the reason.

@rustdesk Shall we add retries when the mailer meets email: lettre::transport::smtp::Error { kind: Network, source: Custom { kind: InvalidData, error: AlertReceived(ProtocolVersion) } } for some specifed smtp servers?

rustdesk commented 9 months ago

Why have this error? You can ask chatgpt to get more understanding before add retry, and choose the best retry strategy.

dignow commented 9 months ago

The server has a singleton mailer instance.

It is only reset on server init and smtp update.

If server init failed, it will also skip update when smtp settings are the same.

rustdesk commented 9 months ago

The server has a singleton mailer instance.

It is only reset on server init and smtp update.

If server init failed, it will also skip update when smtp settings are the same.

How does this relate to retry?

rustdesk commented 9 months ago

Why init fail?

rustdesk commented 9 months ago

@Apashh https://github.com/rustdesk/rustdesk-server-pro/releases/tag/1.1.10-4 could you try it out?

Apashh commented 9 months ago

@Apashh https://github.com/rustdesk/rustdesk-server-pro/releases/tag/1.1.10-4 could you try it out?

Test and all is good ! Thanks !

CLU91 commented 8 months ago

We receive same error like mentioned in: https://github.com/rustdesk/rustdesk-server-pro/issues/26

And also we receive error like in the old thread that has been closed: https://github.com/rustdesk/rustdesk-server-pro/issues/75

Support couldn't help us either..... we use 587 with a lot of systems and especially Linux Servers.

rustdesk commented 8 months ago

Please try out https://github.com/rustdesk/rustdesk-server-pro/issues/99#issuecomment-1755332344 and https://github.com/rustdesk/rustdesk-server-pro/issues/26#issuecomment-1668711541, paste the output, We will follow up

CLU91 commented 8 months ago

Mails are sent correctly with the simple mail test script! But the error on the web console remains.... here is the output:

Regarding https://github.com/rustdesk/rustdesk-server-pro/issues/26#issuecomment-1668711541 ... when i command: openssl s_client -connect smtp.office365.com:587 -starttls smtp

the output is the following:

CLU91 commented 8 months ago

web console

is it >=1.1.10-4?

We on 1.1.10-5 currently, but was also the same problem in 1.1.9

rustdesk commented 8 months ago

same server? docker?

CLU91 commented 8 months ago

We run on Ubuntu 22.04.3 LTS and i do not know what you mean by "same server". We have one server for Rustdesk, installed via your install script. Mail Server of course on a different system.

rustdesk commented 8 months ago

If possible, please send your mail host to support@rustdesk.com

CLU91 commented 8 months ago

If possible, please send your mail host to support@rustdesk.com

We do not have 587 opened to public. Just specific hosts in the cloud, like the rustdesk server for example

rustdesk commented 8 months ago

can you show us web console smtp settings page snapshot?

CLU91 commented 8 months ago

ERROR with STARTTLS Active:

ERROR with STARTTLS not active: