title: sending an email from java
body: <p>i have been trying to send an email from my servlet. I tried to see how this can be done in the internet. But, in all the codes that I came across, none of them used the senders password to send the mail.</p>
  
  <p>This means anyone can send an email from anyone's account. have I got it wrong or what is the actual matter?</p>
  
  <pre><code>Exception in thread "main" javax.mail.MessagingException: Could not connect to S
  MTP host: localhost, port: 465;
    nested exception is:
          java.net.ConnectException: Connection refused: connect
          at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1391)
          at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:41
  2)
          at javax.mail.Service.connect(Service.java:288)
          at javax.mail.Service.connect(Service.java:169)
          at javax.mail.Service.connect(Service.java:189)
          at Email1.main(Email1.java:19)
  Caused by: java.net.ConnectException: Connection refused: connect
          at java.net.DualStackPlainSocketImpl.connect0(Native Method)
          at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketI
  mpl.java:69)
          at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.ja
  va:339)
          at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocket
  Impl.java:200)
          at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java
  :182)
          at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
          at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
          at java.net.Socket.connect(Socket.java:579)
          at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:612)
          at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:160
  )
          at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
          at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
          at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
  </code></pre>