Java MailAPI - Q


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Java MailAPI - Q

  1. #1
    Join Date
    Apr 2005
    Posts
    6

    Java MailAPI - Q

    Hi,
    I tried using the java mail api to send emails, the program compiles fine, but I dont receive any emails, maybe someone can help,
    Heres part of the code, thx in advance
    Code:
    	public void actionPerformed(ActionEvent evt)
        	{
        		if(evt.getSource()==send)
        		{
        			to.setText("IT WORX");
        		String msg_recip = "setec@eircom.net";
            String msg_subject = "test email";
            String msg_body = "test";
            Message mesg;
        	Session session;
        	Properties props = new Properties();
        	props.put("mail.eircom.net", "www.eircom.net");
        	session = Session.getDefaultInstance(props, null);
        	session.setDebug(true); 
        	try {
        		mesg = new MimeMessage(session);
        		
        		mesg.setFrom(new InternetAddress("setec@eircom.net"));
        		InternetAddress toAddress = new InternetAddress(msg_recip);
        		mesg.addRecipient(Message.RecipientType.TO, toAddress);
        		
        		mesg.setSubject(msg_subject);
        		mesg.setText(msg_body);
        		Transport.send(mesg);
        	}
        	catch (MessagingException ex){
        		while((ex = (MessagingException)ex.getNextException()) != null){
        			ex.printStackTrace();
        		}
        	}

  2. #2
    Join Date
    Oct 2004
    Posts
    311
    code looks ok, it is however possible that the mailserver you are using blocks strange SMPT traffic...

  3. #3
    Join Date
    Apr 2005
    Posts
    6
    thx. no, eircom is fine with that sort of stuff. Any other ideas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center