I have created email account in my website(ex: info@mywebsite.com) to use it for sending clients feedback.please guide me in jsp code to solve problem..

Dani AI

Generated

Short summary: the visitor should never be asked for SMTP credentials. The usual, safe pattern is that the web server (JSP/Servlet) accepts the feedback form and then sends the mail on behalf of the site. That keeps credentials and deliverability under server control and matches what ’s example shows (it authenticates the SMTP session), while also answering ’s intent that clients not enter credentials.

Two practical options:

  • Host-side SMTP relay (no per-user auth): use the server's local MTA (sendmail/postfix) or the host's SMTP on localhost and send without mail.smtp.auth. This only works if the host allows it and is safe to configure (avoid creating an open relay).
  • Authenticated SMTP from the server (recommended): the server uses the site account (info@mywebsite.com) to authenticate with the provider (SMTP with TLS on 587 or SMTPS 465). Visitors only POST the form; the server authenticates and sends.

Example (server-side sending with JavaMail / Jakarta Mail — run from a servlet/JSP handler; set the site address as From and put the visitor address in Reply‑To):

Properties p = new Properties();
p.put("mail.smtp.host","smtp.example.com");
p.put("mail.smtp.port","587");
p.put("mail.smtp.auth","true");
p.put("mail.smtp.starttls.enable","true");

Session s = Session.getInstance(p, new Authenticator(){
  protected PasswordAuthentication getPasswordAuthentication(){
    return new PasswordAuthentication("info@mywebsite.com","SMTP_PASSWORD");
  }
});

MimeMessage m = new MimeMessage(s);
m.setFrom(new InternetAddress("info@mywebsite.com","Website"));
m.setRecipients(Message.RecipientType.TO, "info@mywebsite.com");
m.setReplyTo(new Address[]{ new InternetAddress(userEmail) });
m.setSubject(subject);
m.setText(body);
Transport.send(m);

Troubleshooting (for the “did not work connect” error): check the SMTP host/port; confirm whether TLS (STARTTLS) or SSL is required; verify firewall/host blocks on outbound SMTP (many hosts block port 25); confirm credentials and authentication method; inspect the exception stacktrace for AuthenticationFailedException or MessagingException; test connectivity from the server (telnet/openssl) and review hosting provider docs or support. Also validate and sanitize all form fields (reject CR/LF in headers) and add CAPTCHA/rate limits to avoid spam or abuse.

Recommended Answers

All 6 Replies

Inline Code Example Here

@ roe.calingasan where is the example code....

Member Avatar for Member #949455

I have created email account in my website(ex: info@mywebsite.com) to use it for sending clients feedback.please guide me in jsp code to solve problem..

Read this ( it has an example that you can used ) :

@LastMitch! I want the code , without authentication to send feedback to email account in my website(ex: info@mywebsite.com) but in that example it needs to check authentication.In practically I think client does not want to provide their authentication.Can you help me without authentication code for any user can send their feedback to my said email account in my website.

Has anyone help me in this ....

Member Avatar for Member #949455

@LastMitch! I want the code , without authentication to send feedback to email account in my website(ex: info@mywebsite.com) but in that example it needs to check authentication.

You can't modify the code?

The example in the link you can modify code to whatever you want.

Can you help me without authentication code for any user can send their feedback to my said email account in my website.

I'm not going to modify the code for you because it looks very simple to do.

I'm not going to do your job.

From the things you said, you want me to do your work I don't do that.

@ LastMitch I have tried... but did not work connect.. that is why i needed your help but you took it other way.. sorry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.