Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Email in php

  1. #1

    Email in php

    Voglio inviare una mail in php con la funzione mail. Ho scritto una funzione che prende 4 parametri (mittente, destinatario, soggetto e corpo dell'email - in html) li passa a mail e restituisce true o false.
    La funzione va bene e l'email arriva solo che:

    1 nn arriva in html
    2 non viene visualizzato il mittente che scrivo io nelle header
    3 il mittente del campo FROM finisce nella riga del soggetto.

    la funzione è la seguente:


    function sendMailHtml($fStrMittente,$fStrDestinatario,$fSub ject,$fStrBody){

    /* ### VARIABILI GESTIONE URL ASSOLUTI ### */

    $strHost=trim($_SERVER['SERVER_NAME']);

    /*
    ### SETTA IL VALORE DELLA CARTELLA DOVE SI TROVA IL SITO. ###
    ### QUANDO E' ON LINE LA VARIABILE DEVE ESSERE VUOTA. ###
    */
    $strUrlPath="";



    /* ### CORPO PRINCIPALE DELLA MAIL ###*/
    //== al centro viene inserita la tabella che varia a seconda delle mail che vengono inviate ==

    $strHTML= " <html> \n"
    . " <head> \n"
    . " <link rel='stylesheet' type='text/css' href='http://" . $strHost . $strUrlPath . "/css/mail_style.css'> \n"
    . " </head> \n"
    . " <body topmargin='0' leftmargin='0'> \n"
    . " <div style='text-align:center;'> \n"
    . " <table border='0' cellpadding='0' cellspacing='0' width='760' height='113'> \n"
    . " <tr> \n"
    . " <td width='100%' bgcolor='#4F88E8' height='90'> \n"
    . " <div style='text-align:center;'> \n"
    . " <table border='0' cellpadding='0' cellspacing='0' width='760' height='94'> \n"
    . " <tr> \n"
    . " <td rowspan='2' height='94'> \n"
    . " \n"
    . " </td> \n"
    . " <td width='470' colspan='2' height='58'> \n"
    . " \n"
    . " </td> \n"
    . " </tr> \n"
    . " <tr> \n"
    . " <td width='285' style='border-left: 1 solid #89AFEF; border-bottom: 1 solid #89AFEF' height='36'> \n"
    . " </td> \n"
    . " <td height='36' width='285' style='border-bottom: 1 solid #89AFEF'> \n"
    . " <table border='0' cellpadding='0' cellspacing='0'> \n"
    . " <tr> \n"
    . " <td width='49%'> \n"
    . " \n"
    . " </td> \n"
    . " <td width='51%'> \n"
    . " \n"
    . " </td> \n"
    . " </tr> \n"
    . " </table> \n"
    . " </td> \n"
    . " </tr> \n"
    . " </table> \n"
    . " </div> \n"
    . " </td> \n"
    . " </tr> \n"
    . " </table> \n"
    . " <table border='0' cellpadding='0' cellspacing='0' width='760' height='700' style='background-color:#89afef;'> \n"
    . " <tr> \n"
    . " <td width='140' style='background-color:#6597EB;vertical-align:top;'> \n"
    . " \n"
    . " </td> \n"
    . " <td style='vertical-align:top;'>" . $fStrBody . "</td> \n"
    . " <td width='140' style='background-color:#6597EB;vertical-align:top;'> \n"
    . " \n"
    . " </td> \n"
    . " </tr> \n"
    . " </table> \n"
    . " <div style='text-align:center;'> \n"
    . " <table class='foot' border='0' cellpadding='5' cellspacing='0' width='760px'> \n"
    . " <tr> \n"
    . " <td width='100%' style='text-align:center;color:#000080;'> \n"
    . " www.fallasa.it ® 1999-2003
    Qualsiasi riproduzione \n"
    . " parziale o totale dei contenuti di carattere grafico, \n"
    . " testuale, databases e scripting è severamente vietata \n"
    . " dai webmaster e dalla legge italiana sul copyright. \n"
    . " </td> \n"
    . " </tr> \n"
    . " </table> \n"
    . " <table border='0' cellpadding='2' cellspacing='0' width='760' style='background-color: #000080'> \n"
    . " <tr> \n"
    . " <td width='50%'></td> \n"
    . " <td width='50%'></td> \n"
    . " </tr> \n"
    . " <tr> \n"
    . " <td width='50%'></td> \n"
    . " <td width='50%'></td> \n"
    . " </tr> \n"
    . " </table> \n"
    . " </div> \n"
    . " </body> \n"
    . " </html> \n";


    /* ### IMPOSTA HEADER ### */
    $strHeader= " MIME-Version: 1.0 \r\n"
    . " Content-type: text/html; charset=iso-8859-1 \r\n"
    . " From: " . $fStrMittente ." \r\n";




    $blnSentMail=mail($fStrDestinatario,$fSubject,$fSt rBody,$strHeader);


    return $blnSentMail;

    }

    e viene chiamata così:

    $strMittente=trim($_POST["mittente"]);
    $strDestinatario=trim($_POST["destinatario"]);
    $strSoggetto=trim($_POST["soggetto"]);
    $strMessaggio=trim($_POST["messaggio"]);


    sendMailHtml($strMittente,$strDestinatario,$strSog getto,$strMessaggio);


    mi dite dove sbaglio?

    grazie a chi mi aiuta!


    ps: ho ricevuto le mail sia con un client via web sia con outlook ed il problema è lo stesso!
    I dilettanti costruirono l'Arca, i professionisti il Titanic!

  2. #2

    Re: Email in php

    Prova così dove imposti l'header
    From:nome<indirizzo vero email>\nMime-Version: 1.0\nContent-Type: text/html;\n

  3. #3
    Perfetto ora funziona grazie mille!!!
    Ma non si doveva usare il doppio carattere di ritorno a capo e nuova linea per separare gli header? Mha!!!!
    I dilettanti costruirono l'Arca, i professionisti il Titanic!

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 © 2025 vBulletin Solutions, Inc. All rights reserved.