Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    form mail from anonymous

    Ciao a tutti,
    ho utilizzato questo codice jeremy-fry.com/2008/10/20/form-validator per un form php + jquery.
    Funziona alla perfezione se non fosse che la mail che arriva all'indirizzo da me indicato presenta come mittente anonymous@web... etcc.

    Non riesco a far comparire la mail del mittente.

    Ecco il send.php

    Codice PHP:
    <?php $email_text ""; foreach($_POST as $key => $value){     if($value != ""){$email_text.="
    "
    .ucfirst(str_replace("_"" ",$key))." - ".stripcslashes($value);} }  $to "jeremy.m.fry@gmail.com"$subject "Form Reply"$header "MIME-Version: 1.0\n" "Content-type: text/html; charset=utf-8\n"; if(mail($to$subject$email_text$header)){     //This message gets display to user on success     echo "Thank you for your comments!"; }else{     //Message displayed to user on failure     echo "Error!"; } ?>
    index.html:

    Codice PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html>     <head>         <title></title>         <link rel='stylesheet' href='style.css' type='text/css' media='all' />         <script type="text/javascript" src="jquery.js"></script>         <script type="text/javascript" src="form.js"></script>         <script language="javascript">                  </script>     </head>     <body> <div> <form id="myform"> <fieldset>     <ul class="form">         <li class="form_head"> Email isn't required but if you want a response be sure to include it!         <li class="who"> <label for="form_name">My name is</label><span class="required">Required</span>             <input id="form_name" class="is_required" name="Name" type="text" />         <li class="why"> <label for="form_reason">I'm sending this because</label><span class="required">Required</span>         <select id="form_reason" class="is_required" name="Reason"> <optgroup label="Personal"></optgroup> <option>I wanna talk</option> <option>I like your site</option> <option>I hate your site</option> <option>I live in Detroit too!</option> <optgroup label="Coding"></optgroup> <option>we need to share ideas</option> <option>you have an error on your site</option> <option>I want to know how you did something</option> <optgroup label="Buisness"></optgroup> <option>I'm interested in design services</option> <option>I'd like to use your code in a app I'm selling</option> <option>I want to advertise on your site</option> </select>             <li class="where"> <label for="form_location">I live in</label><span class="required"> </span>          <input id="form_location" name="Location" type="text" />         <li class="email"> <label for="form_email">My email address is</label><span class="required"> </span>             <input id="form_email" class="vemail" name="Email" type="text" />         <li class="comments"> <label for="form_comment">Comments</label><span class="required">Required</span>             <textarea id="form_comment" class="is_required" name="Comment"></textarea>         <li class="submit"> <input id="send_contact" type="submit" value="Send" />     [/list]</fieldset> </form> </div>     </body> </html> 
    Consigli?

    Tks

  2. #2
    Ti suggerisco di iniziare leggendo il manuale ufficiale:

    http://www.php.net/manual/en/function.mail.php Example #2 Sending mail with extra headers.

  3. #3
    Grazie Filippo,
    ho provato a seguire l'esempio da te indicatomi ma continua a darmi lo stesso risultato.
    Probabilmente confondo qualche variabile.

    Ho fatto così:

    Codice PHP:
    <?php $email_text ""; foreach($_POST as $key => $value){     if($value != ""){$email_text.="
    "
    .ucfirst(str_replace("_"" ",$key))." - ".stripcslashes($value);} }  $to "nobody@example.com"$subject "Form Reply"$headers 'From: [email]webmaster@example.com[/email]' "\r\n" .'Reply-To: [email]webmaster@example.com[/email]' "\r\n" 'X-Mailer: PHP/' phpversion(); if(mail($to$subject$email_text$header)){     //This message gets display to user on success     echo "Thank you for your comments!"; }else{     //Message displayed to user on failure     echo "Error!"; } ?>

  4. #4
    Per prima cosa, quando posti del codice, cerca di far si che venga visualizzato correttamente.

    Per seconda cosa, in fase di sviluppo è caldamente consigliabile abilitare la visualizzazione degli errori.

    Se abiliti la visualizzazione degli errori ti renderai subito conto della causa del problema.

  5. #5
    Filippo ho seguito i tuoi consigli. Ho trovato l'errore, l'ho corretto, ma la situazione è ancora come nel primo post.

    Che fare?


    Codice PHP:
    <?php  error_reporting(E_ALL); ini_set('display_errors'1); ?>  

    <?php 
    $to      
    'nobody@example.com'
    $subject 'the subject'
    $message 'hello'
    $headers 'From: [email]webmaster@example.com[/email]' "\r\n" .'Reply-To: [email]webmaster@example.com[/email]' "\r\n" 'X-Mailer: PHP/' phpversion();      
             
    if(
    mail($to$subject$message$headers)){ 

    echo 
    "Thank you for your comments!";

     }else{ 
        
    echo 
    "Error!"; }   ?>

  6. #6
    Ho appena testato il codice del manuale ufficiale su 2 server diversi e funziona perfettamente.

    Contatta il tuo fornitore di hosting per maggiori dettagli sulla personalizzazione delle email (es. l'obbligo di utilizzo di -f).

  7. #7
    Ok grazie Filippo

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.