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

SMTPS wire and unit test for SMTPS protocol #50

Merged
merged 8 commits into from
Aug 22, 2016
Merged

Conversation

amihaiemil
Copy link
Member

@amihaiemil amihaiemil commented Aug 17, 2016

PR for #46
Also added SMTPS wire, since Protocol.SMTPS does not work with smtp transport, it needs smtps transport.

Updated javadocs too since they were not ok.

Fixed bug in Protocol.SMTPS which was setting some properties for smtp protocol, not for smtps.

More details:

1) This SMTPS Wire is needed since the Greenmail unit test does not work with the SMTP wire .

This issue was not found before since apparently Gmail server works fine if called with the SMTP wire and SMTPS protocol.

I am not sure why Gmail worked with the SMTP wire, but it works with this SMTPS wire as well, so I would leave this as it is now, since it makes sense the most: If you send an email through SMTPS protocol, a smtps transport should be used.

2) Properties from Protocol.SMTP were not ok since the smtps transport used in the SMTPS wire looks up the properties with ".smtps." in the middle, not ".smtp.". If it does not find them, the defaults are used (localhost and port 465) and so the unit test passed locally, but failed on the linux server since you need root priviledge to access ports < 1024 .

@dmarkov
Copy link

dmarkov commented Aug 17, 2016

@amihaiemil Many thanks, I will find someone to review it before we merge

@dmarkov
Copy link

dmarkov commented Aug 17, 2016

@mkordas it's yours, please review

.putAll(new Protocol.SMTP(this.host, this.port).entries())
.put("mail.smtps.auth", Boolean.TRUE.toString())
.put("mail.smtps.host", this.host)
.put("mail.smtps.port", Integer.toString(this.port))
Copy link
Member Author

@amihaiemil amihaiemil Aug 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkordas Properties from Protocol.SMTP were not ok since the smtps transport used in the SMTPS wire looks up the properties with ".smtps." in the middle, not ".smtp.". If it does not find them, the defaults are used (localhost and port 465) and so the unit test passed locally, but failed on the linux server since you need root priviledge to access ports < 1024 .

Copy link

@mkordas mkordas Aug 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil please address these comments to me now

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil perfect, thanks!

@mkordas
Copy link

mkordas commented Aug 17, 2016

@amihaiemil we meet again, I'll try to do intial review today :)

@mkordas
Copy link

mkordas commented Aug 17, 2016

@amihaiemil I'm on it

@@ -42,11 +42,13 @@
* <pre> Postman postman = new Postman.Default(
* new SMTP(
* new Token("user", "password").access(
* new Protocol.SMTPS("smtp.gmail.com", 587)
* new Protocol.SMTP("bind", "port")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil what's the reason for this change?

Copy link
Member Author

@amihaiemil amihaiemil Aug 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkordas Gmail does not work with SMTP protocol through SMTP wire, so the Javadoc was somewhat misleading. It's usually the first thing anyone tries, so you don't want your first example to not work.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil but isn't it better to provide real SMTPS gmail address instead of bind?

Copy link
Member Author

@amihaiemil amihaiemil Aug 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkordas I don't know what you mean - that is the only pair of bind/port google provides for sending email, and as I said above, it does not work with SMTP protocol through SMTP wire. If I leave it there, it's not a good example since it does not work. People will start looking into their code or simply assume there's a bug in our lib.

This is a javadoc for SMTP, not for SMTPS.
And I don't have other examples of bind/port pairs... but it's a pretty common thing I wouldn't worry. If someone doesn't know what bind and port are, then they for sure have never heard of SMTP and sending email libs.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amihaiemil thanks for explanation, my bad - now I understand

@mkordas
Copy link

mkordas commented Aug 17, 2016

@amihaiemil see my review above

@amihaiemil
Copy link
Member Author

@mkordas done

@mkordas
Copy link

mkordas commented Aug 18, 2016

@amihaiemil I'm on it :)

@mkordas
Copy link

mkordas commented Aug 18, 2016

@amihaiemil very nice, just 2 open comments I think

@amihaiemil
Copy link
Member Author

@mkordas I added a higher timeout for the Greenmail server startup (one of the previous builds failed and it said in the logs that the timeout should be raised)

@mkordas
Copy link

mkordas commented Aug 19, 2016

@amihaiemil sure, I'll cheek it soon

@mkordas
Copy link

mkordas commented Aug 19, 2016

@amihaiemil I'm on it

@mkordas
Copy link

mkordas commented Aug 19, 2016

@amihaiemil really nice!

@mkordas
Copy link

mkordas commented Aug 19, 2016

@rultor merge

@rultor
Copy link
Contributor

rultor commented Aug 19, 2016

@rultor merge

@mkordas Thanks for your request. @yegor256 Please confirm this.

@mkordas
Copy link

mkordas commented Aug 20, 2016

@yegor256 ping

@mkordas
Copy link

mkordas commented Aug 21, 2016

@yegor256 ping again

@yegor256
Copy link
Member

@rultor try to merge

@rultor
Copy link
Contributor

rultor commented Aug 22, 2016

@rultor try to merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 677558c into jcabi:master Aug 22, 2016
@rultor
Copy link
Contributor

rultor commented Aug 22, 2016

@rultor try to merge

@yegor256 Done! FYI, the full log is here (took me 4min)

@dmarkov
Copy link

dmarkov commented Aug 24, 2016

@mkordas 43 mins added to your account (payment number 57bd6f53eac88362ecf9d08f), many thanks for your contribution! 141 hours and 3 mins spent here.

you're getting extra minutes here (c=28)

+43 added to your rating, current score is: +4744

@dmarkov
Copy link

dmarkov commented Aug 24, 2016

@rultor deploy pls

@rultor
Copy link
Contributor

rultor commented Aug 24, 2016

@rultor deploy pls

@dmarkov OK, I'll try to deploy now. You can check the progress here

@rultor
Copy link
Contributor

rultor commented Aug 24, 2016

@rultor deploy pls

@dmarkov Done! FYI, the full log is here (took me 6min)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants