Sending Emails from java using specific Gmail accont -
i have email hosting account company gmail , trying send emails account in java facing following error:
javax.mail.authenticationfailedexception: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=akgnsbsf 534-5.7.14 i7zvgrt2ia4he_atvycpueorgulhg4yvg6hw_jgdagbyukbfjysvdr_xvkzlzzqp88f-un 534-5.7.14 aogu0un-ubur91zw7jsbzeq8ojr6fejfqcpsvkpv9glaupy3ee-puk3y6enabfea8dgdlu 534-5.7.14 fndqwlg_r1i5-veywj8qe73r833f8phwfurancjtkypjqogqo-vrbg6omrzhsp3i-8wphr 534-5.7.14 ajvaiqquhwnrurmkjyk6rkajnyaia> please log in via web browser , 534-5.7.14 try again. 534-5.7.14 learn more @ 534 5.7.14 https://support.google.com/mail/answer/78754 w77sm17182835wmw.10 - gsmtp
and here properties using in code:
final string username = "email@mycompnay.com"; final string password = "********"; final string host = "smtp.gmail.com"; final string port = "587"; // creating properties object properties props = new properties(); // defining properties props.put("mail.smtp.host", host); props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.user", username); props.put("mail.password", password); props.put("mail.port", port); // authorized session object. session mailsession = session.getinstance(props, new javax.mail.authenticator() { @override protected passwordauthentication getpasswordauthentication() { return new passwordauthentication(username, password); } });
so clear, email (myemail@mycompany.com) , mycompany.com emails hosted on gmail. , if replace email gmail email (email@gmail.com) works properly, problem here , how solve it.
i think problem properties mail.smtp.port
, mail.smtp.socketfactory.port
please specify if not , change port number should work fine you.
try set of properties... code must work (a working code added running project)
v_objproperties = new properties(); v_objproperties.put("mail.smtp.host","smtp.gmail.com"); v_objproperties.put("mail.smtp.auth", "true"); v_objproperties.put("mail.debug", "false"); v_objproperties.put("mail.smtp.port",25); v_objproperties.put("mail.smtp.socketfactory.port",25); v_objproperties.put("mail.smtp.starttls.enable", "true"); v_objproperties.put("mail.transport.protocol", "smtp"); v_objsession = session.getinstance(v_objproperties, new authenticator() { @override protected passwordauthentication getpasswordauthentication() { return new passwordauthentication("abc@abc.com", "*********"); } });
Comments
Post a Comment