How can I send this generated XML as an attachment file instead of printing it?
<?php
    $message = '<?xml version="1.0" encoding="UTF-8"?>'."\r\n".
    '<?ADF VERSION="1.0"?>'."\r\n".
    '<adf>'."\r\n".
    '</adf>'."\r\n";
    $headers .= 'Content-Type: text/plain; charset="utf-8"'."\r\n";
    $headers .= 'From: <Testing>'."\r\n";
    mail('my@email.it', 'Subject', $message, $headers);
?>
Modified my project with phpmailer, work perfect with an XAML file attachment:
<?php
require 'class.phpmailer.php';
$mittente = "info@mysite.it";
$nomemittente = "Test mail";
$destinatario = "web@mysite.it";
$ServerSMTP = "smtp.mysite.it";  //server SMTP autenticato Hosting Solutions
$corpo_messaggio = "Grazie per averci contattato!!";
$messaggio = new PHPMailer;
// utilizza la classe SMTP invece del comando mail() di php
$messaggio->IsSMTP(); 
$messaggio->SMTPAuth   = true;     // abilita autenticazione SMTP
$messaggio->SMTPKeepAlive = "true";
$messaggio->Host  = $ServerSMTP;
$messaggio->Username   = "info@mysite.it";      // utente server SMTP autenticato
$messaggio->Password   = "aaaaa";    // password server SMTP autenticato
$messaggio->From   = $mittente;
$messaggio->FromName = $nomemittente;
$messaggio->AddAddress($destinatario); 
$messaggio->Body = $corpo_messaggio;
$messaggio->AddAttachment("test.xml"); 
if(!$messaggio->Send()) {
    echo "errore nella spedizione: ".$messaggio->ErrorInfo;
} else {
    echo "messaggio inviato correttamente";
}
?>
But I need to create XML inline, so not external file, something like this:
 $message = '<?xml version="1.0" encoding="UTF-8"?>'."\r\n".
    '<?ADF VERSION="1.0"?>'."\r\n".
    '<adf>'."\r\n".
    '</adf>'."\r\n";