hi guys
i want your help i want to send email from private company email to yahoo or gmail company using java i will be thankful for any help

Re: send email from java 80 80
Re: send email from java 80 80

i see this page before and i downloaded the java mail but i cannot send an email from a yahoo to a yahoo but it work fine if i send email from gmail to a yahoo mail so my question if the from email that i want to send emails is for a private company email will it work????

Re: send email from java 80 80

If you have access to the SMTP server, then yes.

Re: send email from java 80 80

there something i donot know what is the smtp server?? and how i can know what smtp server? thank you for help

Re: send email from java 80 80

STMP is your outgoing mail server. If you don't know what it is, you will need to ask your network administrators about accessing it. Once you have that, you can follow the examples in the documentation.

Re: send email from java 80 80

hi look for this code it should work but it is not working

 String to = "ggggggggg@yahoo.com";
           Properties props;props = new Properties();
           props.put("mail.smtp.host", "smtp.yahoo.com");
           props.put("mail.smtp.auth", "true");
          props.setProperty( "mail.smtp.port", "587" );
           props.put("mail.smtp.starttls.enable", "true");

 Session session;
           session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
     protected javax.mail.PasswordAuthentication getPasswordAuthentication(){
        return new javax.mail.PasswordAuthentication("wwwww@yahoo.com", "ttttttttttt");
     }});
           try{
           MimeMessage message; 
                message   = new MimeMessage(session);
 message.setFrom(new InternetAddress("wwwww@yahoo.com"));//Sender Id.
 message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
 message.setSubject("Hello!");
 message.setText("Testing from Java Application.......");

// send message.
 javax.mail.Transport.send(message);
 System.out.println("message sent successfully");}
           catch(MessagingException e){
             throw new RuntimeException();  
 } 
Re: send email from java 80 80

What the error/exception are you getting?

PS: this link was posted 4 years ago and seems to be similar to what you are trying to do.

Re: send email from java 80 80

i have no error but no message sent and the print statement doesnot apper

Re: send email from java 80 80

Is it a free Yahoo email account or a paid Yahoo Mail Plus account? Free accounts can't use SMTP.

Re: send email from java 80 80

thank you for help it is a free account so the code is true what about the port no?

Re: send email from java 80 80

I have no idea. That would depend on Yahoo's settings, but if it's a free account it doesn't matter anyway.

Re: send email from java 80 80

well, if I understood the question correctly, the recipient is supposed to be either yahoo or gmail, so whether or not it is free or paid for is not really important.

Re: send email from java 80 80

it is true but if i make the sender email is a yahoo email it will not send the message but if i send it from a gmail it will send the message but the sender email it is neither gmail or yahoo so my question is what part of the code i should change if the sending email is private company email??????

Re: send email from java 80 80

A private company email will have its own STMP propeties and accounts. You need to use those.

Be a part of the DaniWeb community

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