技术标签: 响应服务器535 5.7.1 unab
i am making an auto send email java project using javamail api. when i send this mail using smtp.gmail.com host, it works. But when i use my own host server mail.sitename.com...it shows exception..my username and password are right. Please anyone help me to sort out this problem...
Exception is:-
javax.mail.AuthenticationFailedException: 535 authentication failed (#5.7.1)
at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at com.zenga.servlet.MailNotification.sendMail(MailNotification.java:130)
at com.zenga.servlet.MailNotification.doPost(MailNotification.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Codes:---
a) i am using DAO pattern for data fetching for to(email id ) purpose
b) a jsp file to take start and limit to fetch no of connection to those i am gonna send emails..
c) Servlet file is given below...
package com.zenga.servlet;
import java.io.*;
import java.security.GeneralSecurityException;
import java.util.*;
import com.sun.mail.util.MailSSLSocketFactory;
import com.zenga.dao.DaoFactory;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.mail.*;
import javax.mail.internet.*;
/**
* Servlet implementation class send
*/
@WebServlet("/send")
public class MailNotification extends HttpServlet {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
HashMaplist = new HashMap();
Set> set = null;
Iterator> itr = null;
int start = 0;
int limit = 0;
Map.Entry me = null;
try {
DaoFactory dao = DaoFactory.getDao();
start = Integer.parseInt(request.getParameter("start"));
limit = Integer.parseInt(request.getParameter("end"));
list = dao.insertLimit(start,limit);
set = list.entrySet();
itr = set.iterator();
while(itr.hasNext()) {
me = (Map.Entry)itr.next();
sendMail(me.getKey(),me.getValue(),request,response);
}
} catch (Exception e) {
}
}
private void sendMail(String toUsername, String to,HttpServletRequest request,HttpServletResponse response) throws IOException, GeneralSecurityException {
final String from = "[email protected]";
final String subject = "a subject";
final String password = "password";
final String host = "mail.sitename.com";
String msg = getMessage(toUsername);
//Set the host SMTP address
/*MailSSLSocketFactory socketFactory= new MailSSLSocketFactory();
socketFactory.setTrustAllHosts(true);
Properties properties=System.getProperties();
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.user", from);
properties.put("mail.smtp.password", password);
//properties.put("mail.smtp.starttls.enable","true");
properties.put("mail.smtp.ssl.socketFactory", socketFactory);
properties.put("mail.smtp.EnableSSL.enable","true");
// properties.put("mail.smtp.ssl.enable","false");
properties.put("mail.smtp.ssl.trust",host);
properties.put("mail.protocol.ssl.trust", host);
properties.put("mail.smtp.socketFactory.port", "587");
properties.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.port", "587");
properties.put("mail.smtp.auth", "true");
*/
Properties properties=System.getProperties();
properties.put("mail.smtp.host",host);
properties.put("mail.smtp.user",from);
properties.put("mail.smtp.password",password);
properties.put("mail.smtp.port","587");
properties.put("mail.smtp.auth","true");
// properties.put("mail.smtp.starttls.enable","true");
properties.put("mail.smtp.ssl.enable","false");
properties.put("mail.smtp.starttls.enable","false");
Authenticator auth = new Authenticator(){
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(from,password);
}
};
Session session=Session.getDefaultInstance(properties,auth);
response.setContentType("text/html");
try{
// create a message
MimeMessage message=new MimeMessage(session);
// set the from and to address
// InternetAddress addressFrom = new InternetAddress(from);
message.setFrom(new InternetAddress(from));
//InternetAddress addressTo = new InternetAddress(to);
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
// Setting the Subject and Content Type
message.setSubject(subject);
// create and fill the first message part
MimeBodyPart msgBodypart = new MimeBodyPart();
msgBodypart.setText(msg,"ascii","hmtl");
// create the Multipart and add its parts to it
Multipart multipart=new MimeMultipart();
multipart.addBodyPart(msgBodypart);
// add the Multipart to the message
message.setContent(multipart);
// set the Date: header
message.setSentDate(new Date());
Transport.send(message);
success++;
}
catch(MessagingException me)
{
failed++;
me.printStackTrace();
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
}
I have tried everything that is in comment as well but nothing worked. i read many stackoverflow examples and no one is solving it correctly.
文章浏览阅读488次。那些年,和我们一起成长的应届生们在云和恩墨,有这样一个专业化团队,他们深耕于数据技术服务一线,围绕客户数据系统全生命周期需求,提供端到端的软件产品、专业服务和解决方案,持续为客户创造价值,..._云和恩墨适合应届生吗
文章浏览阅读708次。为了让自己的数据类能够做到最大化的重用,就写个能够重用的PDO操作MySql的类:由于pdo可以连接现在流行的各种数据库,所以单独的写个配置类类来完成不同数据库DSN的配置:/** * 类标准说明 PDO连接数据库的配置类 * 类名: ConfigDataBase * 功能说明: 为了让代码重用,利用此类可以动态的连接各种数据库 * 参数说明:_hcoder 数据库操作类基于pdo class db { private static $operater; private $t
文章浏览阅读1.7k次,点赞4次,收藏3次。通常我们都将html元素分为块级元素、行内元素以及行内块级元素,但是今天冲浪时发现一个将html元素分类的新名词对——替换元素和非替换元素,其实也可以称为置换元素和非置换元素。接下来就记录一下个人对于这个新名词对的一些浅显见解,如有问题,还望大佬指出~目录一、替换元素1.定义2.举例说明3.替换元素有哪些二、非替换元素1.定义2.举例说明3.非替换元素有哪些一、替换元素1.定义一个内容不受CSS视觉格式化模型控制,CSS渲染模型并不考虑对此内容的渲染,且元素本身一般拥有固有尺寸(宽度,高度,宽高._置换元素和非置换元素
文章浏览阅读1.4w次,点赞5次,收藏21次。VyOS是基于Linux的网络操作系统,可提供基于软件的网络路由,防火墙和VPN功能。VyOS项目于2013年底开始,是Vyatta Core 6.6R1的GPL部分的社区分支,目的是维护一个自由和开源的网络操作系统,以响应终止Vyatta社区版本的决定。在这里,每个人都喜欢学习,老一辈的经理和新用户。VyOS主要基于Debian GNU / Linux和Quagga路由引擎。其配置语法和CLI大致是从XORP项目建模的Juniper JUNOS派生而来的,该项目是Vyatta的原始路由引擎。..._vyos图形界面
文章浏览阅读92次。破世界纪录了 0.74 秒!用 Python 实现自动扫雷!相信许多人很早就知道有扫雷这么一款经典的游(显卡测试)戏(软件),更是有不少人曾听说过中国雷圣,也是中国扫雷第一、世界综合排名第二的郭蔚嘉的顶顶大名。扫雷作为一款在Windows9x时代就已经诞生的经典游戏,从过去到现在依然都有着它独特的魅力:快节奏高精准的鼠标操作要求、快速的反应能力、刷新纪录的快感,这些都是扫雷给雷友们带来的、只属于扫雷的独一无二的兴奋点。▍0x00 准备准备动手制作一套扫雷自动化软件之前,你需要准备如下一些工具/软件_自动扫雷软件
文章浏览阅读2.4k次,点赞4次,收藏12次。这个问题困扰了我很久。今天终于解决了,记录一下。造成这个结果的原因是cuda编译版本与runtime版本不符。安装的是10.0版本,也就是/usr/local/cuda-10.0(默认安装目录)。nvcc -V的结果是7.5。apt list|grep nvidia-cuda-tookit显示版本为7.5,找到原因了。卸载掉sudo apt autoremove nvidia-cuda-toolkit把安装版本加入环境变量export LD_LIBRARY_PATH=$LD_LIBRA_nvcc -v和nvidia -smi输出版本不一样
文章浏览阅读811次,点赞23次,收藏24次。Debug:是供程序员使用的调试工具,它可以用于查看程序的执行流程,也可以用于追踪程序执行过程来调试程序。步骤1:加断点步骤2:运行Debug步骤3:下一步 F7步骤4:结束Debug 点击stop红点Object类是所有类的父类,是java.lang包下的核心类(java.lang下的所有包默认直接导入)所有类都可以继承Object中允许被继承的方法所有java类都是直接或间接集成Object类,如果一个类不继承任何一个类,那么它默认继承Object类。
文章浏览阅读1k次,点赞38次,收藏26次。[Java 27周年] 我与Java的缘善于对自己提问题,这个为什么,那个为什么,只有这样,你才会提升和前进。
文章浏览阅读324次。软件要易于修改:最近在看一本书《代码整洁之道:程序员的职业素养》,这本书里面说到,代码设计要遵循一个重要的原则-易于修改,并且要实现这个目标就应该经常修改它,而不是等到大量积累了臃肿代码之后再进行深度重构。 一套完善的测试用例是修改代码的安全保障:而如何保证在频繁修改优化代码之后,不影响其原本的功能呢?那就是要编写一套完善的测试用例,能覆盖到所有的链路场景,通过测试用例的执行结果来确保代码修改的正确性。特别是我们做金融场景业务的开发,尤其要注意代码的正确性、安全性,那么写好单测是不可或缺的_写单元测试用例的工作经历
文章浏览阅读854次。[导读]说到打印机,相信各位并不陌生,但是轮到使用打印机可怕是许多朋友都未曾接触过的。比如说打印机安装驱动操作方法,电脑如何连接打印机,想必这些是许多朋友的疑问。下面我们就来说说打印机如何安装驱动、电脑如何连接打印机。说到打印机,相信各位并不陌生,但是轮到使用打印机可怕是许多朋友都未曾接触过的。比如说打印机安装驱动操作方法,电脑如何连接打印机,想必这些是许多朋友的疑问。下面我们就来说说打印机如何安..._如何连接电脑与打印机并正确安装打印机驱动
文章浏览阅读2.5k次。我的源码 public Session getCurrentSession() { Session session = null; System.out.println("这是baseDao的session"); try { session = sessionFactory.getCurrentSession(); } catch (Exception e) { // ..._illegalargumentexception: removing a detached instance
文章浏览阅读1w次。create or replace procedure proc1isp_name sut.name%type;beginselect name into p_name from sut where id='12072226';dbms_output.put_line(p_name);end proc1;/注意定义方式_oracle写存储过程怎么定义变量