Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to send g mail using smtp using javax.mail. It works locally but when I deploy my application on AWS-elastic-beanstalk I'm getting StackOverflowError.

I am trying to send g mail using smtp using javax.mail. It works locally but when I deploy my application on AWS-elastic-beanstalk I'm getting StackOverflowError.

this is my code

 Session newSession = null; MimeMessage mimeMessage = null; private String fromUser = "fromUser"; private String padd = "pass"; protected void setupServerProperties() { Properties properties = System.getProperties(); properties.put("mail.smtp.port", "587"); properties.put("mail.smtp.auth", "true"); properties.put("mail.smtp.starttls.enable", "true"); properties.put(properties, properties); newSession = Session.getDefaultInstance(properties, null); } protected void sendEmail() throws MessagingException { // String fromUser = "test"; // String padd="pass2"; String emailHost = "Smtp"; Transport transport = newSession.getTransport("smtp"); transport.connect(emailHost, fromUser, padd); transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients()); transport.close(); System.out.println("*****successfull*****"); } protected MimeMessage draftEmail(String Body) throws AddressException, MessagingException { String[] emailReceiptes = { "receipt" }; String emailSubject = "Test Mail"; String emailbody = Body; mimeMessage = new MimeMessage(newSession); for (int i = 0; i < emailReceiptes.length; i++) { mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(emailReceiptes[i])); } mimeMessage.setSubject(emailSubject); MimeBodyPart bodyPart = new MimeBodyPart(); bodyPart.setContent(emailbody, "text/html"); MimeMultipart multiPart = new MimeMultipart(); multiPart.addBodyPart(bodyPart); mimeMessage.setContent(multiPart); return mimeMessage; } 

Code is working fine When I am running it on my local server but when I am trying to run it on Elastic beanstalk (My Server is running on AWS EBS) then StackOverflowError.

Note : I have turn ON access to less Secure app from Google A/c Setting but still I am getting this error.

****************The answers on Chegg isn't right***************

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago