I am using this function to send an email, but this does nto work..
What's wrong?? =(
<?php
$SMTP = "mailer2.mondoweb.it";
$TO = "test@yobilab.com";
function InviaMail($subject, $body, $hdrs) {
global $SMTP, $TO;
ini_set("SMTP", $SMTP);
mail($TO, $subject, $body, $hdrs);
}
$subject = "Clevery. Richiesta informazioni su: ". $_POST['offerta'] .".";
$body = "Clevery. Richiesta informazioni su: ". $_POST['offerta'] ."<br><br>" .
"Nome cliente: " . $_POST['nome'] . "<br>" .
"Email: " . $_POST['email'] . "<br>" .
"Referente: " . $_POST['referente'] . "<br>" .
"Città: " . $_POST['citta'] . "<br>" .
"Provincia: " . $_POST['provincia'] . "<br>" .
"Telefono: " . $_POST['telefono'] . "<br>" .
"Note: " . $_POST['commento'] . "<br>";
$hdrs = "Content-Type: text/html; charset=iso-8859-1\n" . "From: "开发者_JAVA技巧 .
"\"clevery.it\" <info@clevery.it>";
InviaMail($subject, $body, $hdrs);
?>
<?php
function InviaMail($subject, $body, $hdrs) {
global $SMTP, $TO;
ini_set("SMTP", $SMTP);
if(mail($TO, $subject, $body, $hdrs)===true){
return true;
}else{
return false;
}
}
echo (InviaMail($subject, $body, $hdrs)===true)?'Mail was sent.':'Error Sending mail.'
?>
SMTP used Port 25 to send mails which is blocked by most of the ISP's to check if it is the problem with your code or your ISP try doing this.
echo mail($to, $subject, $body, $hdrs) ? 'Mail Sent Successfully' : 'There was an error sending mail';
Try the above code.
精彩评论