“This is my first day to participate in the Gwen Challenge.
Dockerfile
Build an image from a simple Dockerfile (consumer-service-rabbitMQ /v1.0)
FROM openjdk:8-alpine
MAINTAINER maishuren
EXPOSE 8001
ADD target/consumer-rabbit-1.0-SNAPSHOT.jar /
ENTRYPOINT ["java"."-jar"."/ consumer - rabbit - 1.0 - the SNAPSHOT. Jar"]
Copy the code
Run the container
Docker run - d - name consumer - service - the rabbitmq - v1.0 - p, 8001:8001 - v/etc/timezone: / etc/timezone - v The/etc/localtime: / etc/localtime consumer - service - the rabbitmq/v1.0Copy the code
Yml configuration
Yml configuration for sending emails
spring:
mail:
port: 465
host: smtp.qq.com
username: Qq email
password: Authorization code and so on
from: Qq email
properties:
mail:
smtp:
auth: true
socketFactory:
port: 25
class: javax.net.ssl.SSLSocketFactory
fallback: false
starttls:
enable: true
required: true
Copy the code
After running, an error is reported when sending an email. Because SMTP uses port 25 by default to send mail, port 25 is not open when the container is run.
Redeploy the container to open port 25
Docker run - d - name consumer - service - the rabbitmq - v1.0 - p, 8001:8001 - p - v/etc/timezone: when the/etc/timezone - v The/etc/localtime: / etc/localtime consumer - service - the rabbitmq/v1.0Copy the code
After the deployment is successful, the above error is reported when invoked again. After some twists and turns, IT was found that the server manufacturer shielded port 25. I heard that the server I deployed used Ali Cloud server can apply for unlocking port 25. But instead of requesting unblocking, I use another port to send emails.
Redeploy using port 465 to send mail
spring:
mail:
port: 465
host: smtp.qq.com
username: Qq email
password: Authorization code and so on
from: Qq email
properties:
mail:
smtp:
auth: true
socketFactory:
port: 465
class: javax.net.ssl.SSLSocketFactory
fallback: false
starttls:
enable: true
required: true
Copy the code
Redeploying the container
Docker run - d - name consumer - service - the rabbitmq - v1.0 - p, 8001:8001 - p, 465:465 - v/etc/timezone: / etc/timezone - v The/etc/localtime: / etc/localtime consumer - service - the rabbitmq/v1.0Copy the code
Finally, the mail sending interface is invoked, and the mail is successfully sent
conclusion
In fact, the problem is that the server port 25 is blocked, change the port to send mail