1.E' sufficiente utilizzare due volte la funzione mail(), una per l'email all'utente, una per la tua:
Codice PHP:
function SendEmail(){
include("header.php");
global $db, $prefix, $email, $username, $site_name, $site_email, $site_url;
nav_menu();
echo "<form method=\"POST\" action=\"users.php\">
<table align=\"center\" border=\"0\" width=\"500\" cellpadding=\"2\">
<tr>
<td colspan=\"2\" align=\"center\">Spedisci email a ($username)</td>
</tr>
<tr>
<td width=\"100\">To:</td>
<td><input type=\"text\" name=\"email\" size=\"27\" value=\"$email\"></td>
</tr>
<tr>
<td>Oggetto:</td>
<td><input type=\"text\" name=\"subject\" size=\"27\" value=\"\"></td>
</tr>
<tr>
<td valign=\"top\">Messaggio:</td>
<td>Salve $username,
<textarea rows=\"20\" name=\"msg\" cols=\"80\">Testoooo
</textarea>
---------------------
$site_name
$site_url
</td>
</tr>
<tr>
<td></td>
<td><input type=\"hidden\" name=\"action\" value=\"do_SendEmail\">
<input type=\"submit\" value=\"INVIA\"></td>
</tr>
</table>";
include("footer.php");
}
function do_SendEmail(){
global $email, $username, $subject, $msg, $site_name, $site_email, $site_url;
$message = "Salve $username,\n\n";
$message .= "$msg\n\n\n\n";
$message .= "-----------------------\n";
$message .= "$site_name\n";
$message .= "$site_url\n";
$to = $email;
$header = "From: $site_name <$site_email>\n";
$header .= "Reply-To: $site_email\n\n";
$mailallutente = mail($to, $subject, $message, $header);
$to = "mio indirizzo";
$mailame = mail($to, $subject, $message, $header);
if($mailallutente&&$mailame)){
msg_redirect("".LOGIN." ".EFFETTUATO." ".CON." ".SUCCESSO."","users.php","5");
}else{
echo "<h3>"
."<font color=\"#FF0000\">An error occurred while sending the email.
"
."</font>You can try:
"
."1- Check the email is correct.
"
."2- Call your hosting provider to allow the function mail(); to send E-mails.
"
."3- If your running the script on localhost (on your pc) you have to:
"
."a: edit php.ini file. Click on (Start) menu then chose (Run) type in (php.ini) and hit Enter.
"
."b: Look for:
"
."------------------
"
."[mail function]
"
."; For Win32 only.
"
."SMTP = localhost
"
."-------------------
"
."replace with:
"
."-------------------
"
."[mail function]
"
."; For Win32 only.
"
."SMTP = mail.palnet.com
"
."SMTP_PORT = 25
"
."-------------------
"
."you can change mail.palnet.com to any local email provide. we just need there mail server";
}
}
2.temo che non che dipenda dalla codifica della mail, comunque, a mio parere, la cosa migliore è utilizzare una mail in html, che può contenere qualsiasi carattere speciale. Per fare ciò, è sufficiente specificarlo negli header della mail:
Codice PHP:
function SendEmail(){
include("header.php");
global $db, $prefix, $email, $username, $site_name, $site_email, $site_url;
nav_menu();
echo "<form method=\"POST\" action=\"users.php\">
<table align=\"center\" border=\"0\" width=\"500\" cellpadding=\"2\">
<tr>
<td colspan=\"2\" align=\"center\">Spedisci email a ($username)</td>
</tr>
<tr>
<td width=\"100\">To:</td>
<td><input type=\"text\" name=\"email\" size=\"27\" value=\"$email\"></td>
</tr>
<tr>
<td>Oggetto:</td>
<td><input type=\"text\" name=\"subject\" size=\"27\" value=\"\"></td>
</tr>
<tr>
<td valign=\"top\">Messaggio:</td>
<td>Salve $username,
<textarea rows=\"20\" name=\"msg\" cols=\"80\">Testoooo
</textarea>
---------------------
$site_name
$site_url
</td>
</tr>
<tr>
<td></td>
<td><input type=\"hidden\" name=\"action\" value=\"do_SendEmail\">
<input type=\"submit\" value=\"INVIA\"></td>
</tr>
</table>";
include("footer.php");
}
function do_SendEmail(){
global $email, $username, $subject, $msg, $site_name, $site_email, $site_url;
$message = "Salve $username,\n\n";
$message .= "$msg\n\n\n\n";
$message .= "-----------------------\n";
$message .= "$site_name\n";
$message .= "$site_url\n";
$to = $email;
$header = "From: $site_name <$site_email>\r\n";
$header .= "Reply-To: $site_email\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mailallutente = mail($to, $subject, $message, $header);
$to = "mio indirizzo";
$mailame = mail($to, $subject, $message, $header);
if($mailallutente&&$mailame)){
msg_redirect("".LOGIN." ".EFFETTUATO." ".CON." ".SUCCESSO."","users.php","5");
}else{
echo "<h3>"
."<font color=\"#FF0000\">An error occurred while sending the email.
"
."</font>You can try:
"
."1- Check the email is correct.
"
."2- Call your hosting provider to allow the function mail(); to send E-mails.
"
."3- If your running the script on localhost (on your pc) you have to:
"
."a: edit php.ini file. Click on (Start) menu then chose (Run) type in (php.ini) and hit Enter.
"
."b: Look for:
"
."------------------
"
."[mail function]
"
."; For Win32 only.
"
."SMTP = localhost
"
."-------------------
"
."replace with:
"
."-------------------
"
."[mail function]
"
."; For Win32 only.
"
."SMTP = mail.palnet.com
"
."SMTP_PORT = 25
"
."-------------------
"
."you can change mail.palnet.com to any local email provide. we just need there mail server";
}
}
Spero di esserti stato utile!