Results 1 to 5 of 5
  1. #1
    nwboy74 is offline Member
    Join Date
    Oct 2008
    Posts
    45
    Rep Power
    0

    Default [SOLVED] Sending Email via UNIX

    I have a Java application that I need to send out an email report after it finishes. The application is running on a unix machine. Normally with Perl, I just open a file descriptor like
    Java Code:
    open(FH, "|mailx -s 'Some Subject' recipient");
    Then I can write to it and it delivers the email. But I'm not sure how to accomplish this with Java. I am not able to install any Java add-ons.

  2. #2
    rock_star is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default

    try javamail APIs

  3. #3
    nwboy74 is offline Member
    Join Date
    Oct 2008
    Posts
    45
    Rep Power
    0

    Default

    Is that an add-on? I've got Java 5.0 jre to work with.

  4. #4
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    If you don't want to mess with javamail, you can simply spawn a process to do whatever you want using Runtime.exec(). You could use dtmail or whatever for that purpose.

  5. #5
    nwboy74 is offline Member
    Join Date
    Oct 2008
    Posts
    45
    Rep Power
    0

    Default

    Thank you. It works!

    Java Code:
    try {
        String[] cmd = {"mailx", "-s Test Email", "someuser"};
        Process p = Runtime.getRuntime().exec(cmd);
        OutputStreamWriter osw = new OutputStreamWriter(p.getOutputStream());
        osw.write("I am a test email");
        osw.close();
    } catch (java.io.IOException ioe) {
    }

Similar Threads

  1. Need help sending an email
    By isshino in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-19-2009, 08:35 PM
  2. sending a simple email message via SMTP
    By chahhchahh in forum Networking
    Replies: 5
    Last Post: 03-08-2009, 06:58 PM
  3. Communicate between Windows and UNIX
    By nwboy74 in forum Networking
    Replies: 10
    Last Post: 11-04-2008, 08:53 PM
  4. send email using apache commons email
    By jnamendi in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 10-14-2008, 05:55 PM
  5. sending email without SMTP?
    By java_srinivasan in forum Advanced Java
    Replies: 1
    Last Post: 07-23-2008, 03:45 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
  •