0

I am using XAMPP for deploying my java application in tomcat and also using mercury mail to ssend emails. Now i am just testing my application with a small java program using java mail API and mercury email. I havee done the necessary configuration in Mercury to setup localhost. My program is running successfully without any error. Also Mercury log file doesn't say anything about any error.

T 20130411 044359 51663963 Connection from 127.0.0.1
T 20130411 044359 51663963 EHLO 10.226.44.101
T 20130411 044359 51663963 MAIL FROM:<[email protected]>
T 20130411 044359 51663963 RCPT TO:<*****@gmail.com>
T 20130411 044359 51663963 DATA
T 20130411 044359 51663963 DATA - 22 lines, 689 bytes.
T 20130411 044359 51663963 QUIT
T 20130411 044359 51663963 Connection closed with 127.0.0.1, 0 sec. elapsed.

Also this is my java file....

public static void main(String [] args) {

      // Recipient's email ID needs to be mentioned.
      String to = "****@gmail.com";

      // Sender's email ID needs to be mentioned
      String from = "[email protected]";

      // Assuming you are sending email from localhost
      String host = "localhost";
      String password = "****";

      // Get system properties
      Properties properties = System.getProperties();

      // Setup mail server
      properties.setProperty("mail.smtp.host", host);

   // Setup mail server
      properties.setProperty("mail.smtp.password", password);

      // Get the default Session object.
      Session session = Session.getDefaultInstance(properties);

      try{
         // Create a default MimeMessage object.
         MimeMessage message = new MimeMessage(session);

         // Set From: header field of the header.
         message.setFrom(new InternetAddress(from));

         // Set To: header field of the header.
         message.addRecipient(Message.RecipientType.TO,
                                  new InternetAddress(to));

         // Set Subject: header field
         message.setSubject("This is the Subject Line!");

         // Create the message part 
         BodyPart messageBodyPart = new MimeBodyPart();

         // Fill the message
         messageBodyPart.setText("This is message body");

         // Create a multipar message
         Multipart multipart = new MimeMultipart();

         // Set text message part
         multipart.addBodyPart(messageBodyPart);

         // Part two is attachment
         messageBodyPart = new MimeBodyPart();
         String filename = "C:/Users/toshiba/Desktop/file.txt";
         DataSource source = new FileDataSource(filename);
         messageBodyPart.setDataHandler(new DataHandler(source));
         messageBodyPart.setFileName(filename);
         multipart.addBodyPart(messageBodyPart);

         // Send the complete message parts
         message.setContent(multipart );

         // Send message
         Transport.send(message);
         System.out.println("Sent message successfully....");
      }catch (MessagingException mex) {
         mex.printStackTrace();
      }

I am absolutely clueless about it..... Also my Mercury core process says it has 4 pending outgoing jobs....???

7
  • Your question is unclear. The line RCPT TO:<*****@gmail.com> would indicate that your mail agent should forward the email to a gmail address, not deliver it locally. If that's the case, it is likely Gmail is discarding the mail based on the source IP address. Apr 10, 2013 at 23:48
  • i put the stars in line RCPT TO:<*****@gmail.com>. My question is if there iss no error on log file as well as java file then what i need to do extra to receive email on my gmail acc Apr 10, 2013 at 23:58
  • it looks to me like your code is trying to connect to a mailsever running on localhost... do you have one running?
    – Tony
    Apr 11, 2013 at 0:19
  • yes...XAMPP...its running Apr 11, 2013 at 0:22
  • you might want to try this video: youtube.com/watch?v=_QnfF64rA78
    – Tony
    Apr 11, 2013 at 0:24

1 Answer 1

0

The destination address is at gmail. You haven't clarified if the mail was supposed to be delivered locally or at gmail, so I'm going to assume you meant the mail to go to a Gmail account, which you've (correctly) obfuscated in your post.

The session transcript you posted is between your Java client and the local Mercury mail server. All this says is that the local Mercury mail server accepted the mail from your Java client.

The session transcript contains no information about what happened to the mail after your local Mercury mail server accepted it. If the local configuration was correctly set up, then Mercury mail should have tried to forward the mail by looking up the MX record for Gmail and connecting to one of the servers returned by the MX lookup.

For further information you will have to look at the Mercury server's logs to see if it attempted to deliver the message.

A guess:

Your Mercury mail server attempted to deliver the mail, but Gmail rejected it because the computer you are running on has an ISP-assigned DHCP (dynamic) address. A large volume of SPAM originates from such addresses, and many mail hosts refuse to even talk to these mail sources. In any event, if Gmail rejected it, Mercury mail is required to "bounce" it back to the sender. However, you probably have not set up an incoming mailbox for [email protected], so it had no place to store the bounce and just discarded it. Again, check the Mercury mail logs for details.

That's the best answer anyone can give based on the information you have provided.

6
  • Thank you very much Jim for the detailed answer.Actually i have setup the incoming mailbox also for [email protected] and I'm able to send email to this account. But as you said i am not getting bounced mail on this account. Also if i try to send email to any small email provider unlike Gmail, do i have any chance to get the email delivered? Also what information you want other than this to clarify my post more... Apr 11, 2013 at 6:36
  • You could start with your external IP address (the one on the externally-facing side of your gateway/router) and the name of the ISP. Apr 11, 2013 at 6:47
  • The router's HTML interface page will be able to tell you. Read the manual for the router to figure out how to access the page. Apr 11, 2013 at 6:52
  • 192.168.1.137 is your internal IP, not the router's external address (the one seen by other computers on the Internet) Apr 11, 2013 at 6:52
  • That address in rDNS is 241647hfc174.tampabay.res.rr.com, which is highly likely to be ignored by Gmail. I administer an SMTP server and my automated SPAM prevention would not accept an email from that address. Apr 11, 2013 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.