Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4027310
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:04:52+00:00 2026-05-20T11:04:52+00:00

I want to send an email ussing an EJB but i the only thing

  • 0

I want to send an email ussing an EJB but i the only thing i get in return in this exception:

java.lang.RuntimeException: javax.mail.AuthenticationFailedException: failed to connect, no password specified?

This is how my EJB looks like:

@Stateless(name = "ejbs/EmailServiceEJB")
public class EmailServiceEJB extends Authenticator implements IEmailServiceEJB {

public PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication("xxxxxxx@gmail.com",
            "xxxxxxx");
}

public void sendAccountActivationLinkToBuyer(String destinationEmail,
        String name) {
    // OUR EMAIL SETTINGS
    String host = "smtp.gmail.com";// Gmail
    int port = 465;
    String serviceUsername = "xxxxxxx@gmail.com";
    String servicePassword = "xxxxxxx";// Our Gmail password

    Properties props = new Properties();
    props.put("mail.smtp.user", serviceUsername);
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.port", port);
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.debug", "true");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.socketFactory.port", port);
    props.put("mail.smtp.socketFactory.class",
            "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.socketFactory.fallback", "false");

    // Destination of the email
    String to = destinationEmail;
    String from = "xxxxxxx@gmail.com";

    // Creating a javax.Session with the our properties
    Session session = Session.getInstance(props);

    try {
        Message message = new MimeMessage(session);
        // From: is our service
        message.setFrom(new InternetAddress(from));
        // To: destination given
        message.setRecipients(Message.RecipientType.TO,
                InternetAddress.parse(to));
        message.setSubject("Comfirm your account");
        // Instead of simple text, a .html template should be added here!
        message.setText("Welcome....... ");

        Transport transport = session.getTransport("smtp");
        transport.connect(host, port, serviceUsername, servicePassword);
        Transport.send(message, message.getAllRecipients());
        transport.close();

    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }

}

}

I dont know why it keeps saying that the password is not specified? Does the SSLSocketFactory have something to do with it? Do i need to call the getPasswordAuthenticion() method somewhere, or calling the second method from my managed bean is all i need?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:04:52+00:00Added an answer on May 20, 2026 at 11:04 am

    I don’t know why your code isn’t working, but you might want to take a look at this:

    http://spitballer.blogspot.com/2010/02/sending-email-via-glassfish-v3.html

    It shows an alternate method of configuring email in Java EE, which I think works much better. The connection details are configured at the container level, just like a container-managed database connection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to write application who send email using outlook and i found this
I want send a email by Email Class in codeigniter with gmail, but i
I want to send email through Java (Any email like from yahoo, gmail, or
I have a WCF web service. I want to send email from this service.
I want to send email to Yahoo mail using Indy. But Yahoo uses 465
Our customers want to send emails from our java appengine application using their email
I want to send email on the gmail account. When i use this it
I am trying to send Email using Java Sockets but cannot seem to send
How can I send an HTML-formatted email with pictures using PHP? I want to
I want to send email with my gmail account, I gave it a try,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.