2 Replies - 299 Views - Last Post: 24 June 2010 - 03:25 PM Rate Topic: -----

#1 abgorn  Icon User is offline

  • sudo apt-get install brain
  • member icon

Reputation: 30
  • View blog
  • Posts: 1,409
  • Joined: 05-June 08

JavaMail Email Class Sending 2 Emails instead of one

Posted 24 June 2010 - 12:45 PM

This is the code:
class SendmailExample {

    public SendmailExample() throws NoSuchProviderException, MessagingException {
        Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");

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

            @Override
                    protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication("abgorn", "***********");
                    }
                });

        try {

            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("abgorn@gmail.com"));
            message.setRecipients(Message.RecipientType.TO,
                    InternetAddress.parse("abgorn@hotmail.com"));
            message.setSubject("Testing");
            message.setText("Shut up foo'!");


            Transport.send(message);

            System.out.println("Done");

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



It does send an email from my Gmail account to my Hotmail but also the Gmail (even though it's sending from that account). I don't want this to happen. At first I thought I had to allocate the message to the sent box and by default it goes to the inbox, this is not the case. It appears in the sent inbox anyway. Does anyone know how I can stop this?

Is This A Good Question/Topic? 0
  • +

Replies To: JavaMail Email Class Sending 2 Emails instead of one

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2557
  • View blog
  • Posts: 10,672
  • Joined: 20-September 08

Re: JavaMail Email Class Sending 2 Emails instead of one

Posted 24 June 2010 - 01:25 PM

afaik you can't control how Google implements its mail - you're in their hands
Was This Post Helpful? 1
  • +
  • -

#3 abgorn  Icon User is offline

  • sudo apt-get install brain
  • member icon

Reputation: 30
  • View blog
  • Posts: 1,409
  • Joined: 05-June 08

Re: JavaMail Email Class Sending 2 Emails instead of one

Posted 24 June 2010 - 03:25 PM

But if I use an email client and send an email from my Gmail account it doesn't send a copy to Gmail account I sent it from. Any clue on this anyone?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1