Web Analytics Made Easy -
StatCounter JavaMail - CodingForum

Announcement

Collapse
No announcement yet.

JavaMail

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • JavaMail

    Im Unable to send the Mail Can anyOne Help me pls It out of reach for me...Thanks in Advanvance Below is my code to send a email using java Program


    import java.util.Date;
    import java.util.Properties;
    import javax.mail.*;

    import javax.mail.internet.*;
    import javax.activation.*;
    import java.io.OutputStream;
    import java.io.File;
    import java.io.FileOutputStream;
    public class SendMail {

    public static void main(String[] args)throws MessagingException
    {
    String smtpHost="smtp.gmail.com";
    String to="[email protected]";
    String from ="[email protected]";
    Properties properties = System.getProperties();
    properties.put("mail.smtp.host", smtpHost);
    properties.put("mail.smtp.port", "465");

    Session session=Session.getInstance(properties,null);
    try
    {
    MimeMessage msg1=new MimeMessage(session);
    msg1.setFrom(new InternetAddress(from));
    msg1.setRecipient(Message.RecipientType.TO, new InternetAddress(to));
    msg1.setText("hi iam from Hyderabad");
    msg1.setSubject("hai");
    msg1.setSentDate(new Date());
    System.out.println("message sent");
    Transport transport = session.getTransport("smtp");
    transport.connect(smtpHost, "[email protected]","password");
    Transport.send(msg1);
    System.out.println("message sent2");

    }
    catch (MessagingException e) {
    e.printStackTrace();
    }
    }

    // TODO: handle exception
    }

  • #2
    And the error / problem you are having is what? Do you get the 'message sent2' in your output?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎