Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 12 of 12

Thread: Mail Sender Application from Localhost

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Mail Sender Application from Localhost

    Hello Team,

    I would like to send an automated mail to the user whenever he registers in my application.

    I am using struts framework for my application.

    What are the pre-requisites to achieve this?

    Please explain in detail how can I do this..


    Thanks & Regards,
    Srinivas Goud N
    srinivasgoudn@gmail.com


  2. #2
    Member
    Join Date
    Nov 2011
    Posts
    37
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Mail Sender Application from Localhost

    Hi,
    Use java mail api to send mail on your specific event.

    Core java
    Last edited by mr.miku; January 11th, 2012 at 07:12 PM.

  3. The Following User Says Thank You to mr.miku For This Useful Post:

    srinivasgoudn (November 14th, 2011)

  4. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Mail Sender Application from Localhost

    I think I need a mail server to do this.

    Can you suggest a free mail server.

    Can you please explain how to configure the mail server???

  5. #4
    Junior Member
    Join Date
    Nov 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Mail Sender Application from Localhost

    Hello Team,

    I would like to send an automated mail to the user whenever he registers in my application.

    I am using struts framework for my application.

    What are the pre-requisites to achieve this?

    Please explain in detail how can I do this..


    Thanks & Regards,
    Srinivas Goud N
    srinivasgoudn@gmail.com

  6. #5
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Mail Sender Application from Localhost

    Did you ever try Java Mail API? If yes, then it is possible to send it through struts as you only have to write the somehow similar code in your Struts Action Class.

    See hmailserver for Windows XP to send emails.
    Last edited by Mr.777; November 18th, 2011 at 04:43 AM.

  7. #6
    Junior Member
    Join Date
    Nov 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Mail Sender Application from Localhost

    OK Thanks...I will try it..

  8. #7
    Junior Member
    Join Date
    Nov 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Mail Sender Application from Localhost

    Hi,

    Can you please tell me how to configure Hmail server for sending mails using Gmail's SMTP host & port?

    Thanks,
    Srinivas.

  9. #8
    Junior Member
    Join Date
    Jun 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Mail Sender Application from Localhost

    I have developed many application where i have to do mailing to some one.
    Use java mail api to send email through any server.
    You just have to specify the mail server address and it's port no.Google for the mail server and port no you can find it out.

    @srinivasgoudn smtp host for gmail is "mail.smtp.host" and open port is "587".

  10. #9
    Junior Member
    Join Date
    Nov 2011
    Posts
    11
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Mail Sender Application from Localhost

    Hi,

    Finally I could send mails from my application.

    Thanks to Everyone who helped me to solve the problem.

    Regards,
    Srinivas

  11. #10
    Junior Member
    Join Date
    Oct 2011
    Posts
    11
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Mail Sender Application from Localhost

    hi dude
    can u give code for gmail.com mail address............

  12. #11
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Mail Sender Application from Localhost

    Quote Originally Posted by nagaraj200788@gmail.com View Post
    hi dude
    can u give code for gmail.com mail address............
    1. Read Forums rules.
    2. Don't ask for help unless you provide what you've done so far and where are you stuck.
    3. Don't ask for help in already posted threads.
    4. Create your own Thread.

    NOTE: READ THE FORUMS RULES!!!!!!!

  13. #12
    Junior Member
    Join Date
    Oct 2011
    Posts
    11
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Automailing with gmail

    Hi Java ROCKS
    Can any one give ready made code to do auto mailing with gmail.......................................
    i am having following error...........

    Could not connect to SMTP host: smtp.gmail.com, port: 110;

    this is my code..................


    import java.security.Security;
    import java.util.Properties;

    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;

    public class GoogleTest {

    private static final String SMTP_HOST_NAME ="smtp.gmail.com";
    private static final String SMTP_PORT ="110";
    private static final String emailMsgTxt = "Test Message Contents";
    private static final String emailSubjectTxt = "A test from gmail";
    private static final String emailFromAddress ="nagaraj20july88@gmail.com";
    private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
    private static final String[] sendTo = {"nagaraj20july88@gmail.com"};


    public static void main(String args[]) throws Exception {

    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

    new GoogleTest().sendSSLMessage(sendTo, emailSubjectTxt,
    emailMsgTxt, emailFromAddress);
    System.out.println("Sucessfully Sent mail to All Users");
    }

    public void sendSSLMessage(String recipients[], String subject,
    String message, String from) throws MessagingException {
    boolean debug = true;

    Properties props = new Properties();
    props.put("mail.smtp.host", SMTP_HOST_NAME);
    props.put("mail.smtp.auth", "true");
    props.put("mail.debug", "true");
    props.put("mail.smtp.port", SMTP_PORT);
    props.put("mail.smtp.socketFactory.port", SMTP_PORT);
    props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
    props.put("mail.smtp.socketFactory.fallback", "false");

    Session session = Session.getDefaultInstance(props,
    new javax.mail.Authenticator() {

    protected PasswordAuthentication getPasswordAuthentication() {
    return new PasswordAuthentication("garitammanavara1","garitam manavara1");
    }
    });

    session.setDebug(debug);

    Message msg = new MimeMessage(session);
    InternetAddress addressFrom = new InternetAddress(from);
    msg.setFrom(addressFrom);

    InternetAddress[] addressTo = new InternetAddress[recipients.length];
    for (int i = 0; i < recipients.length; i++) {
    addressTo[i] = new InternetAddress(recipients[i]);
    }
    msg.setRecipients(Message.RecipientType.TO, addressTo);

    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    Transport.send(msg);
    }
    }

Similar Threads

  1. SMS SENDER RECOGNIZER
    By javalearn250 in forum Java Theory & Questions
    Replies: 1
    Last Post: October 4th, 2011, 07:25 AM
  2. Replies: 1
    Last Post: September 8th, 2011, 02:27 PM
  3. Mysql url pointer to server instead of localhost
    By kurt-hardy in forum JDBC & Databases
    Replies: 3
    Last Post: April 12th, 2011, 05:32 AM
  4. JNLP webstart application in localhost
    By Jhovarie in forum Threads
    Replies: 2
    Last Post: February 14th, 2011, 06:53 PM
  5. Replies: 6
    Last Post: September 19th, 2010, 09:33 PM