Sending from a Java Software to a email!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • edin94
    New Member
    • Apr 2010
    • 1

    #1

    Sending from a Java Software to a email!

    Hi

    I have a problem sending this information

    Code:
     
    private void postFormToServer() throws Exception {
      String address = UtilityStore.WBW_SERVER;
            URL url = http://myadress.com/send_mail.php;
            URLConnection connection = url.openConnection();
            connection.setDoOutput(true);
            if(connection instanceof HttpURLConnection) {
             ((HttpURLConnection)connection).setRequestMethod("POST");
            }
            OutputStreamWriter streamWriter = new OutputStreamWriter(connection.getOutputStream());
            streamWriter.write(customerNameField + SEPARATOR + customerInfoField + SEPARATOR + emailField);
            streamWriter.close();
     }
    to this page

    Code:
    <?php
    
    $to = "my mail@gmail.com";
    $emailField= $_POST["emailField"];
    $subject= $_POST["subject"];
    $customerNameField= $_POST["customerNameField"];
    $customerInfoField= $_POST["customerInfoField"];
    
    if (mail ($to, $subject, $customerInfoField ,"From: $customerNameField <$emailField>"))
    
    echo nl2br("<h2>Sent!</h2> 
    <b>mottagare:</b> $to
    <b>ämne:</b> $subject
    <b>meddelande:</b>
    $customerInfoField
    ");
    
    else
    echo "No";
    
    ?>
    Its just not sending the mail, but Im not getting any errors.
Working...