title: Problem while sending mail in java
body: <p>My code runs on a windows server on my machine, but as I upload the same class file to the Linux server machine it does not work.</p>
  
  <p>As there is no error generation, I can't get the exact problem..</p>
  
  <p>See my code below if you could help me.</p>
  
  <pre><code>public static String myemail = "xyz@abc.com", //username
  mypassword = "*************", //password
  myhost = "smtp.abc.com", // smtp address
  myport = "234", // port address
  mysubject = "Hello",
  mytext = "this is just a test mail";
  
  
  public String mail(String recp)
  {
  
      Properties pro = new Properties();
      pro.put("mail.smtp.user", myemail);
      pro.put("mail.smtp.host", myhost);
      pro.put("mail.smtp.port", myport);
      pro.put("mail.smtp.starttls.enable","true");
      pro.put("mail.smtp.auth", "true");
      pro.put("mail.smtp.debug", "true");
      pro.put("mail.smtp.socketFactory.port",myport);
  
  
      SecurityManager security = System.getSecurityManager();
  
      try
      {
          Authenticator authen = new SMTPConfig();
          Session session = Session.getInstance(pro, authen);
          session.setDebug(true);
  
          MimeMessage msg = new MimeMessage(session);
          msg.setText(mytext);
          msg.setSubject(mysubject);
          msg.setFrom(new InternetAddress(myemail));
          msg.addRecipient(Message.RecipientType.TO, new
          InternetAddress(recp));
          Transport.send(msg);
      }
  
      catch (Exception ex)
      {
          ex.printStackTrace();
      }
  
      return null;
  
  }
  
  private class SMTPConfig extends javax.mail.Authenticator
  {
  
      public PasswordAuthentication getPasswordAuthentication()
      {
          return new PasswordAuthentication(myemail, mypassword);
      }
  
  } 
  </code></pre>