内网通过nginx转发邮件,包含安装nginx

1.安装nginx时要安装

./configure   --prefix=/home/weihu/nginx-welcome --with-http_ssl_module --with-mail --with-mail_ssl_module --with-stream  --with-stream_ssl_module  --with-openssl=/home/weihu/nginx/openssl-1.0.2k

注: –with-openssl=/home/weihu/nginx/openssl-1.0.2k是如果内网下不了opssl,就自己下一个放上去
–with-stream –with-stream_ssl_module是必须要的
2.配置文件里面要加:

stream{
	server {
		listen 8465; 
		proxy_connect_timeout 5s;
		proxy_timeout 20s;
		proxy_pass smtp.163.com:465;
	}
}

注:和http模块平级,因为发送邮件必须得用smtp协议,http协议不管用,nginx默认加载http模块用以转发http协议

3.补充nginx安装流程:
1.下载nginx压缩包
2.解压nginx
3.在解压包里面输入./configure –prefix=/home/weihu/nginx-welcome –with-http_ssl_module –with-mail –with-mail_ssl_module –with-stream –with-stream_ssl_module –with-openssl=/home/weihu/nginx/openssl-1.0.2k
4.输入make,这里如果是修改nginx的模块,就把解压包里面的nginx文件替换安装包里面sbin里面的nginx
5.make install 慎用,修改不用输入这个命令

4.后台java:

        properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        properties.setProperty("mail.smtp.socketFactory.fallback", "false");
        properties.setProperty("mail.smtp.ssl.enable", "true");
       //3.连接服务器,需要抛出异常;
        tp.connect(连接外网用来转发的服务器ip,8465, checkMail.getMailSendUsername(), checkMail.getMailSendPassword());
    原文作者:txSong123
    原文地址: https://blog.csdn.net/jockha/article/details/123902378
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞