内网通过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());
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值