Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6115485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:05:48+00:00 2026-05-23T15:05:48+00:00

I read that email program contact’s the author’s ISP email server to pass it

  • 0

I read that email program contact’s the author’s ISP email server to pass it the message.
In the following program i make a successfull connection with SMTP server of gmail.I wanted to send the email from this program ( from gmail account) to rediff account.No where in this program i open the connection to rediff server . But i am successfull in sending the emails. How is that ? I just tested by changing the to address from gmail to rediff and was successful. Here is the program :

// cross mail

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Properties;

class crossmail {
   public static void main(String args[]) {
       Properties props = new Properties();
       props.put("mail.smtp.host", "smtp.gmail.com");
       props.put("mail.stmp.user", "from");
       props.put("mail.smtp.starttls.enable", "true"); 
       props.put("mail.smtp.password", "password");
       props.put("mail.smtp.auth", "true");

       Session session = Session.getDefaultInstance(props, new Athenticator() {     
     @Override
    protected PasswordAuthentication getPasswordAuthentication() {
       String username = "from";
       String password = "paassword";
              return new PasswordAuthentication("from", "paassword");
    }
        });
        String to = "me@rediff";
        String from = "from@gmail.com";
        String subject = "Testing...";
        MimeMessage msg = new MimeMessage(session);
          try {
        msg.setFrom(new InternetAddress(from));
        msg.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(to));
        msg.setSubject(subject);
        msg.setText("Test Successfull...!");
        Transport transport = session.getTransport("smtp");
        transport.send(msg);
        System.out.println("fine!!");
          }   catch(Exception exc) {
            System.out.println(exc);
              }
     }
   }    

How does this email program work ? If i am wrong in my understanding please correct that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:05:49+00:00Added an answer on May 23, 2026 at 3:05 pm

    Email apps RARELY directly contact the recipient’s email server. That’s not what they’re for. Instead, they’ll contact your local SMTP server (running locally on the same server, or your ISP’s) and hand off the mail to that server. That intermediate server then does the hard work of looking up who handles the recipient’s email and contacts that server.

    Part of that process is to look at the recipient’s email address, say fred@example.com, and do a DNS lookup on example.com to get that domain’s MX records. Those (M)ail e(X)changer records specify the “public” mail servers for the domain, where incoming mail should be sent.

    This frees you and your app from ever having to know HOW or WHERE to deliver every piece of mail… all you have to do is know where your local mail server is. Much like you don’t need to know HOW a snailmail letter goes from you to your penpal – all you is write an address on the envelope and drop it into a mailbox. The postal service takes care of all the details in getting the letter from point A to point B.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a simple program for work that does the following: read
I recently read somewhere that writing a regexp to match an email address, taking
I have 2 batch programs, 1 is a program that sends email and another
I'm writing a program to read from a POP3 mailbox and upload the email
I am currently developing application that does following: Read Inbox (using MAPI) & SMS
Hi guys I need to read some email from outlook in a C++ program,
I read that you could call JavaScript code from a Java Applet by calling
I read that Domain Driven Design is about concentrating on the problem domain instead
I read that SQL exceptions are treated as normal exceptions in managed SPs; I
I read that you should define your JavaScript functions in the <head> tag, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.