ho creato una classe per l'invio delle email:
Codice PHP:
<?php

class mail_og {

    private 
$toAddress;
    private 
$ccAddress;
    private 
$bccAddress;
    private 
$fromAddress;
    private 
$subject;
    private 
$sendText;
    private 
$textBody;
    private 
$sendHtml;
    private 
$htmlBody;

    public function 
__construct() {
        
$this->toAddress '';
        
$this->ccAddress '';
        
$this->bccAddress '';
        
$this->fromAddress '';
        
$this->subject '';
        
$this->sendText '';
        
$this->textBody '';
        
$this->sendHtml '';
        
$this->htmlBody '';
    }

    public function 
setToAddress($value) {
        
$this->toAddress $value;
    }

    public function 
setCcAddress($value) {
        
$this->ccAddress $value;
    }

    public function 
setBccAddress($value) {
        
$this->bccAddressAddress $value;
    }

    public function 
setFromAddress($value) {
        
$this->fromAddress $value;
    }

    public function 
setSubject($value) {
        
$this->subject $value;
    }

    public function 
setSendText($value) {
        
$this->sendText $value;
    }

    public function 
setTextBody($value) {
        
$this->sendText true;
        
$this->textBody $value;
    }

    public function 
setSendHtml($value) {
        
$this->sendHtml $value;
    }

    public function 
setHtmlBody($value) {
        
$this->sendHtml true;
        
$this->htmlBody $value;
    }

    public function 
send($to=NULL$subject=NULL$message=NULL$headers=NULL) {
        if (!
is_null($to) && !is_null($subject) && !is_null($message)) { //se almeno i primi tre parametri nn sono nulli
            
$success mail($to$subject$message$headers);
            return 
$success;
        } else {
            
$headers = array();
            if (!empty(
$this->fromAddress)) {
                
$headers[] = 'From: ' $this->fromAddress;
            }
            if (!empty(
$this->ccAddress)) {
                
$headers[] = 'CC: ' $this->ccAddress;
            }
            if (!empty(
$this->bccAddress)) {
                
$headers[] = 'BCC: ' $this->bccAddress;
            }
            if (
$this->sendText && !$this->sendHtml) {
                
$message $this->textBody;
            } else if (!
$this->sendText && $this->sendHtml) {
                
$headers[] = 'MIME-Version: 1.0';
                
$headers[] = 'Content-type: text/html; charset="iso-8859-1"';
                
$headers[] = 'Content-Transfer-Eoncoding: 7bit';
                
$message $this->htmlBody;
            } else if (
$this->sendText && $this->sendHtml) {
                
$boundary '==MP_Bound_xyccr948x==';
                
$headers[] = 'MIME-Version: 1.0';
                
$headers[] = 'Content-type: multipart/alternative; boundary="' $boundary '"';
                
$message 'Messaggio Multipart in formato MIME.' "\n";
                
$message .= '--' $boundary "\n";
                
$message .= 'Content-type: text/plain; charset="iso-8859-1"' "\n";
                
$message .= 'Content-Transfer-Eoncoding: 7bit' "\n\n";
                
$message .= $this->htmlBody "\n";
                
$message .= '--' $boundary "--";
            }

            
$success mail($this->toAddress$this->subject$messagejoin("\r\n"$headers));
            return 
$success;
        }
    }

}

?>
la istanzio in un altro file così:
Codice PHP:
<?php

require 'class.mail.php';
$mail = new mail_og();
$mail->setToAddress('email');
$mail->setFromAddress($_POST['from_address']);
$mail->setCcAddress($_POST['cc_address']);
//$mail->setBccAddress($value);
$mail->setSubject($_POST['subject']);
$mail->setTextBody($_POST['message']);
$mail->setHtmlBody('

html</p>'
);

if (
$mail->send()) {
    echo 
"

Il messaggio è stato inviato

"
;
    echo 
"[b]From:[/b] " $_POST['from_address'] . "
"
;
    echo 
'[b]CC:[/b] ' $_POST['cc_address'] . "
"
;
    echo 
"[b]Subject:[/b] " $_POST['subject'] . "
"
;
    echo 
"[b]Message:[/b]</p>";
    echo 
nl2br($_POST['message']);
    echo 
'
Tra 5 secondi sarai reindirizzato nella home page.'
;
    
header('refresh: 5; url=index.html');
} else {
    echo 
"

[b]C'è stato un errore nell'invio del messaggio![/b]</p>"
;
}
?>
e questo è il form:_
Codice PHP:
        <form method="post" action="sendmail.php">
            <
table>
                <
tr>
                    <
td>Your email: </td>
                    <
td><input type="text" name="from_address" value="" size="40" /></td>
                </
tr>
                <
tr>
                    <
td>CC:</td>
                    <
td><input type="text" name="cc_address" value="" size="40" /></td>
                </
tr>
                <
tr>
                    <
td>Subject:</td>
                    <
td><input type="text" name="subject" value="" size="40" /></td>
                </
tr>
                <
tr>
                    <
td valign="top">Message:</td>
                    <
td><textarea name="message" rows="10" cols="60"></textarea>
                    </
td>
                </
tr>
                <
tr>
                    <
td><input type="submit" value="Send" name="send" /></td>
                    <
td><input type="reset" value="Reset" name="reset" /></td>
                </
tr>
            </
table>
        </
form
avrei due questioni da risolvere:
-vorrei sapere se c'è qualche cosa che dovrei fare per aumentare la sicurezza
-la classe è predisposta per inviare sia testo normale che testo con codice html, ma nn riesco ad inviarli entrambi.
qualche suggerimento??