0

I am currently using this script to send clients mails. But the "From" name in my inbox shows: fullhouseproject1@gmail.com. I'd like to set this name to Full House. How do i do that?

public Mail(Speler speler) throws MessagingException {

    final String username = "fullhouseproject1@gmail.com";
    final String password = "password";

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

    Session session = Session.getInstance(props,
            new javax.mail.Authenticator() {

                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(username, password);
                }
            });

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("Full House"));
    message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse(speler.email));
    message.setSubject("Bevestiging van betaling " + "- Toernooi: " + speler.ToernooiID);
    message.setText("Geachte heer/mevrouw " + speler.naam + ","
            + "\n\n Uw betaling voor toernooi: " + speler.ToernooiID + " is geaccepteerd."
            + "\n\n Met vriendelijke groet,"
            + "\n Full House");

    Transport.send(message);

    System.out.println("Done");

}

}

  • 1
    Please search first before asking a question. The solution to your problem is given in http://stackoverflow.com/questions/1567467/setting-the-from-name-in-a-javax-mail-mimemessage – dirkk Nov 02 '13 at 11:17

1 Answers1

0
 message.setFrom(new InternetAddress("fullhouseproject1@gmail.com","Full House"));
wvdz
  • 16,251
  • 4
  • 53
  • 90
  • This answer is too short and doesn't meet SO quality standard. Please, improve its quality by adding some explanations so that it is useful for the community in general and not only for the OP. – LorenzoDonati4Ukraine-OnStrike Nov 02 '13 at 11:39