Results 1 to 9 of 9
  1. #1

    Angry how to send mail using smtp server from web hosted server

    hi,
    i am doing my final year project..
    i have create an web application which has main feature of sending mails to customers on booking and cancellation.
    this is my code for sending email...

    public void mail()
    {
    final String d_email = "[email protected]";
    final String d_password = "*****";
    String d_host = "smtp.gmail.com", d_port = "465", m_subject = "Discount OFFER";
    class SMTPAuthenticator extends javax.mail.Authenticator
    {
    public PasswordAuthentication getPasswordAuthentication()
    {
    return new PasswordAuthentication(d_email, d_password);
    }
    }
    try{


    Properties props = new Properties();
    props.put("mail.smtp.user", d_email);
    props.put("mail.smtp.host", d_host);
    props.put("mail.smtp.port", d_port);
    props.put("mail.smtp.starttls.enable","true");
    props.put("mail.smtp.auth", "true");
    //props.put("mail.smtp.debug", "true");
    props.put("mail.smtp.socketFactory.port", d_port);
    props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.put("mail.smtp.socketFactory.fallback", "false");
    // props.setProperty("proxySet","true");
    //props.setProperty("http.proxyHost","proxy.ssn.net");
    // props.setProperty("http.ProxyPort","8080");

    // System.setProperty("http.proxyHost", "proxy.ssn.net");
    //System.setProperty("http.proxyPort", "8080");
    SecurityManager security = System.getSecurityManager();

    Authenticator auth = new SMTPAuthenticator();
    Session session = Session.getInstance(props, auth);
    session.setDebug(true);

    MimeMessage msg = new MimeMessage(session);
    msg.setText(m_text);
    msg.setSubject(m_subject);
    msg.setFrom(new InternetAddress(d_email));
    msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to));
    Transport.send(msg);

    }
    catch (Exception mex)
    {
    mex.printStackTrace();
    }

    }



    when i try this code with my system its working well...but after hosting in web no email has be recieved...and i dont know whats wrong with it....



    pls frnds help me...

  2. #2
    Are you getting any error message while sending the email from hosting server ?
    || Eminds Infotech || 9th Year of Server Management Solutions ||
    || Server Management || 24x7 Technical Support || Cloud Management ||
    || 24x7 Live Chat Support || VPS Management || Server Migrations ||
    || https://www.24x7cloudservermanagement.com||

  3. #3
    no...i am not getting error...

  4. #4
    Join Date
    Jan 2005
    Location
    Minneapolis, MN
    Posts
    967
    Host may be blocking the remote SMTP connection. You'll need to check with them.
    Doyle Lewis
    BuyHTTP Internet Services - In business since 2003
    Business Hosting | nginx, CloudLinux, Varnish cache, and CDP with every business account
    Shared, Reseller, Semi Dedicated, VPS, Cloud, Dedicated - We can grow with you

  5. #5
    oh...i am new to web hosting stuff...can you say me wher to check?

  6. #6
    Join Date
    Jan 2005
    Location
    Minneapolis, MN
    Posts
    967
    Contact your host and ask them if they block remote SMTP connections from scripts.
    Doyle Lewis
    BuyHTTP Internet Services - In business since 2003
    Business Hosting | nginx, CloudLinux, Varnish cache, and CDP with every business account
    Shared, Reseller, Semi Dedicated, VPS, Cloud, Dedicated - We can grow with you

  7. #7
    hey keliix06,
    thanku yaar...i found the error and its working...
    the mistake is my web host server has JDK 1.5 and my content has includes mail.jar(lastest version).so i used the mail.jar(1.3 version)...its working fine

  8. #8
    Join Date
    Mar 2011
    Location
    Bangladesh
    Posts
    1
    simply grate ...

  9. #9
    THANKU

Similar Threads

  1. Not able to send mail using SMTP service on Windows 2003 server machin
    By evaedmond in forum Hosting Security and Technology
    Replies: 2
    Last Post: 06-17-2008, 05:04 PM
  2. Send mail from web form using 3rd party SMTP
    By danwednesday in forum Hosting Security and Technology
    Replies: 2
    Last Post: 04-02-2008, 07:34 AM
  3. Cannot send mail through VPS SMTP server. The usual fixes didn't work.
    By elmwood in forum Hosting Security and Technology
    Replies: 3
    Last Post: 02-02-2007, 05:25 PM
  4. Plesk 7 VPS not able to send mail, phpMail or SMTP
    By 15DollarHosting in forum Hosting Security and Technology
    Replies: 4
    Last Post: 11-08-2005, 02:43 PM
  5. Unable to send mail SMTP (Exim Problems?)
    By nick[x1] in forum Hosting Security and Technology
    Replies: 2
    Last Post: 08-17-2004, 09:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •