Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email question: Unable to send mail to mymailid@yahoo.com

Status
Not open for further replies.

aHash

Programmer
Aug 22, 2000
78
US
Hi all,

I am able to send mail to my office account but when I try to send it to out side i.e my yahoo id, I am unable to receive the mail . It does not give any error message also..

Code:
			Email email = new Email();
			email.setContent("Test Email");
			email.setReceipient(user.getUserID());
			email.setReceipientEmail("myID@yahoo.com");
			email.setSubject("Test subject  " );
			email.setSentDate(new Date(System.currentTimeMillis()));
			
			try {
				EmailSender.sendEmail(email);
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			} catch (MessagingException e) {
				e.printStackTrace();
			}

and here is the email sender.

Code:
    public static void sendEmail( Email email ) throws MessagingException, UnsupportedEncodingException {    
        
        //String SYSTEM_EMAIL = SystemProperties.getProperty("system.emailAddress");
        //String SYSTEM_NAME = SystemProperties.getProperty("system.emailDisplay");
        String SYSTEM_EMAIL = "karthik@starry-associates.com";
        String SYSTEM_NAME = "starry-associates.com";
    
        boolean debug = false;
    
        //Set the host smtp address
        Properties props = new Properties();
        props.put("mail.transport.protocol", "smtp");

        /* props.put("mail.smtp.host", SystemProperties.getProperty("system.mailServer"));
           props.put("mail.host", SystemProperties.getProperty("system.mailServer"));      */

        props.put("mail.smtp.host", "mail01");
        props.put("mail.host", "mail01");
        log.debug(props.toString());        
        
        // create some properties and get the default Session
        Session session = Session.getDefaultInstance(props, null);
        session.setDebug(debug);
    
        // create a message
        MimeMessage msg = new MimeMessage(session);
    
        // set the from address and full name
        InternetAddress addrFrom = new InternetAddress(SYSTEM_EMAIL, SYSTEM_NAME);
        msg.setFrom(addrFrom);
        
        // set the replyTo address
        InternetAddress[] addrReplyTo = new InternetAddress[1]; 
        addrReplyTo[0] = new InternetAddress(SYSTEM_REPLY_TO);
        msg.setReplyTo(addrReplyTo);
    
        // set the TO address
        InternetAddress[] addrTo = new InternetAddress[1];
        addrTo[0] = new InternetAddress(email.getReceipientEmail());
        msg.setRecipients(Message.RecipientType.TO, addrTo);
    
        // Setting the Subject and Content Type
        msg.setSubject(email.getSubject());
        msg.setContent(email.getContent(), "text/html");        
        
        // setting the Flag or Priority
        if (email.isFlagged()) {
            Flags flags = new Flags();
            flags.add(Flag.FLAGGED);
            msg.setFlags(flags, true);
            msg.addHeader("Priority", "Urgent");
            msg.addHeader("Importance", "high");            
        }
    
        // properly set the sent date
        msg.setSentDate(new Date(System.currentTimeMillis()));

        log.debug("Sending email from "+email.getSender());

        //String mailServer = SystemProperties.getProperty("system.mailServer");
        //String account = SystemProperties.getProperty("system.mailAccount");
        //String passwd = SystemProperties.getProperty("system.mailPassword");

        String mailServer = "mail01";
        String account = "karthik";
        String passwd = "4321";
        if (passwd==null) passwd="";
    
        // using the non-static version so we can connect with a NULL password
        Transport transport = session.getTransport("smtp");
        transport.connect(mailServer, account, passwd);
        transport.sendMessage(msg, msg.getAllRecipients());
        transport.close();
    }


Thanks to all in advance..

 
I am sorry if this forum is not the right one..
I will post this is java forum..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top