Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STARTTLS support? #30

Closed
Lars- opened this issue Dec 7, 2020 · 12 comments
Closed

STARTTLS support? #30

Lars- opened this issue Dec 7, 2020 · 12 comments

Comments

@Lars-
Copy link

Lars- commented Dec 7, 2020

Is your feature request related to a problem? Please describe.
I would like to send mails via Office365, but I can't seem to find any documentation on STARTTLS.

Describe the solution you'd like
STARTTLS support or the documentation for it.

Describe alternatives you've considered
Nothing yet, MailDroid is already implemented, so it would be great to keep using it.

Additional context
None

@nedimf
Copy link
Owner

nedimf commented Dec 27, 2020

Sure, I'll add it by end of this week. Happy holidays @Lars-

nedimf pushed a commit that referenced this issue Jan 9, 2021
@nedimf
Copy link
Owner

nedimf commented Jan 9, 2021

Hey @Lars- , checkout latest commit for the feature you requested, let me know if it works.

@nedimf nedimf closed this as completed Jan 9, 2021
@Lars-
Copy link
Author

Lars- commented Jan 13, 2021

Unfortunately, it doesn't work:

E/MessagingException: com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp.office365.com, 587; timeout -1;
      nested exception is:
    	java.net.SocketTimeoutException: failed to connect to smtp.office365.com/2603:1026:c03:3030::2 (port 587) after 90000ms

The code that I use:

MaildroidX.Builder maildroidX = new MaildroidX.Builder()
                    .smtp("smtp.office365.com")
                    .smtpUsername("[REDACTED]")
                    .smtpPassword("[REDACTED]")
                    .isStartTLSEnabled(true)
                    .port(String.valueOf(587))
                    .type(MaildroidXType.PLAIN)

                    .to("[REDACTED]")
                    .from("[REDACTED]")
                    .subject("[REDACTED]")
                    .body(body)
                    .onCompleteCallback(new MaildroidX.onCompleteCallback() {
                        @Override
                        public void onSuccess() {
                         // Stuff
                        }

                        @Override
                        public void onFail(String s) {
                            //Stuff
                        }

                        @Override
                        public long getTimeout() {
                            return 5000;
                        }
                    });

When I try it with PHP, it does work. I looked it over a couple of times, but there doesn't seem to be any spelling mistake.
PHP code (using PHPMailer)

        $mail->SMTPDebug = SMTP::DEBUG_OFF;
	$mail->isSMTP();
	$mail->Host       = 'smtp.office365.com';
	$mail->SMTPAuth   = true;
	$mail->Username   = '[REDACTED]';
	$mail->Password   = '[REDACTED]';
	$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
	$mail->Port       = 587;

	$mail->setFrom( '[REDACTED]' );
	$mail->addAddress( '[REDACTED]' );

	foreach ( $files as $file ) {
		$mail->addAttachment( $file );
	}

	$mail->isHTML( false );
	$mail->Subject = $_POST['subject'] ?? '';
	$mail->Body    = $_POST['body'] ?? '';

	$mail->send();

What could the problem possibly be?

@nedimf
Copy link
Owner

nedimf commented Jan 14, 2021

Taking closer look at it, sorry for inconvenience

@Lars-
Copy link
Author

Lars- commented Jan 14, 2021

I appreciate it, thanks! Maybe reopen the issue until it works?

@nedimf
Copy link
Owner

nedimf commented Jan 14, 2021

Did you check this? Maybe it's firewall issue? Let me know if that is the case.
Issue pointing to MS 365 configuration and this

Microsoft Office 365 issue

@nedimf nedimf reopened this Jan 14, 2021
@Lars-
Copy link
Author

Lars- commented Jan 16, 2021

Yep, I checked it. The android app runs on the same network as the PHP script. So that couldn't be the problem.
The only thing that could be it is the verification of the certificate of office365. Maybe that version of Android doesn't know that certificate yet or something like that. Could be tested with a "do not verify certificate" option. I know that isn't safe, but it could explain it.

@nedimf
Copy link
Owner

nedimf commented Jan 16, 2021

Alright, what version of Android is that? @Lars-

@nedimf
Copy link
Owner

nedimf commented Jan 19, 2021

Is issue being resolved? @Lars-

@Lars-
Copy link
Author

Lars- commented Jan 19, 2021

Sorry, missed your comment. It's running on Android 5.1 and unfortunately not upgradeable.

@nedimf
Copy link
Owner

nedimf commented Jan 19, 2021

I'm pretty sure issue is with 5.1 version it self. So library wise I don't see what can be done. SSL seems to work on other versions. @Lars-

@nedimf
Copy link
Owner

nedimf commented Jan 21, 2021

Concluding this is not Maildroid issue. This issue has been addressed.

@nedimf nedimf closed this as completed Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants