ciao
hai provato a guardare qui ?
http://forum.mrwebmaster.it/php/38548-invio-mail-tramite-php.html
ciao
Marino
si , ma non ricevo nessuna mail.
lo script funziona perfettamente ma se lo eseguo nel mio hosting non invia la mail anche se si conclude senza errori
cosa significa funziona perfettamente ?
dove e come lo hai provato ?
hai visto arrivare le mail ?
puoi postare lo script con tutti i parametri, esclusi utenti e password delle mail ma lasciando i domini ?
grazie
ciao
Marino
<body>
<form name="form1" method="post" action="richiesta.php">
<p><label for="nome"></label>None e Cognome (*):<input name="nome" type="text" id="nome" size="30" required="required"></p>
<p><label for="email"></label>Indirizzo e-mail (*):<input name="email" type="text" id="email" size="30" required="required"></p>
<p><label for="note"></label>Messaggio (*): <textarea name="note" cols="70" rows="2" id="note" required="required"></textarea></p>
<p><input type="submit" name="ok" id="ok" value="Invia">(*) campi obbligatori</p>
</form>
</body>
<?php
# [url]http://localhost/test_site/php/test/email_orig.php[/url]
error_reporting(E_ALL); // per segnalare un eventuale errore a video senza guardare il log
ini_set('display_errors', '1');
$mail_username = "pippo"; // account ID registrato con il provider in uso
$mail_password = "pluto"; // password
$mail_SMTP = "smtp.topolino.it"; // indirizzo SMTP del provider
$mail_SMTPport = "25"; // porta del servizio di invio
$mail_from = "From: ".$mail_username; // mittente, può essere diverso da account ID,
// per sicurezza però qualche provider lo vuole uguale
ini_set("SMTP" ,$mail_SMTP);
ini_set("smtp_port",$mail_SMTPport);
ini_set("username" ,$mail_username);
ini_set("password" ,$mail_password);
$nome = $_POST['nome'];
$email = $_POST['email'];
$note = $_POST['note'];
$mittente = "MIME-Version: 1.0\r\n";
$mittente .= "Content-type: text/html; charset=iso-8859-1 \r\n";
$mittente .= $mail_from." \r\n";
$mittente .= "Bcc: [email][email protected][/email] \r\n";
$oggetto = "Richiesta pervenuta al sito: www.pluto.net";
$testo = '
<html><head>
<style type="text/css">body {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px; font-weight:normal; color:#000000;}
</style></head><body><br><br><p><img src="logo.jpg" ></p>';
$testo .= "
<strong>Richiesta</strong><br><br>
nome: ".$nome."<br>
e-mail: ".$email. "<br>
note: ".$note."<br><br><br>
</p></body></html>
";
$destinatario = "[email protected]";
mail($destinatario, $oggetto, $testo, $mittente);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body,td,th {
font-family: Verdana, Geneva, sans-serif;
font-size: 16px;
color: #09C;
text-align: center;
}
a:link {
color: #09C;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #09C;
}
a:hover {
text-decoration: underline;
color: #09C;
}
a:active {
text-decoration: none;
color: #09C;
}
</style>
</head>
<body>
<p> </p>
<p>La sua richiesta e' stata inoltrata</p>
</body>
</html>
ini_set("SMTP" ,$mail_SMTP);
ini_set("smtp_port",$mail_SMTPport);
ini_set("username" ,$mail_username);
ini_set("password" ,$mail_password);
ini_set('display_errors', '1');
ciao, hai provato ad utilizzare la classe phpmailer?
https://github.com/PHPMailer/PHPMailer/
E' davvero semplice, a suo tempo creai per un altro utente un form, te lo allego prova se funziona.
Vedi l'allegato 2156
<?php
# http://localhost/test_site/php/mail/use_gmail.php
include("phpmailer/class.phpmailer.php");
include("phpmailer/class.smtp.php");
$mail = new PHPMailer();
$body = file_get_contents('contents.html'); // testo del messaggio in formato html
$mail->SMTPDebug = 1; // eliminare quando si mette in "produzione"
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "[email protected]"; // mittente
$mail->Password = ""; // password
$mail->FromName = "Nome Utente"; // nome che precede indirizzo e-mail mittente
$mail->From = "[email protected]"; // lascerei uguale al mittente
$mail->AddAddress("[email protected]"); // destinatario 1
$mail->AddAddress("[email protected]"); // destinatario 2
$mail->AddCC("[email protected]");
$mail->AddBCC("[email protected]");
$mail->AddReplyTo("[email protected]"); // rispondere a ...
$mail->Subject = "PROVA DI INVIO SSL";
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body);
// $mail->AddAttachment("/path/to/file.zip");
// $mail->AddAttachment("/path/to/image.jpg", "new.jpg");
$mail->IsHTML(true); // send as HTML
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
?>
SMTP -> ERROR: Failed to connect to server: Connection refused (111)
The following From address failed: [email protected] : Called Mail() without being connected Mailer Error: The following From address failed: [email protected] : Called Mail() without being connected
$mail->SMTPDebug = 1; // eliminare quando si mette in "produzione"
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.tiscali.it";
$mail->Port = 465;
$mail->Username = "[email protected]"; // mittente
$mail->Password = "*********"; // password
$mail->FromName = "Pippo Pluto"; // nome che precede indirizzo e-mail mittente
$mail->From = "[email protected]"; // lascerei uguale al mittente
$mail->AddAddress("[email protected]"); // destinatario 1
$mail->AddCC("[email protected]");
$mail->AddBCC("[email protected]");
$mail->AddReplyTo("[email protected]"); // rispondere a ...
$mail->Subject = "PROVA DI INVIO SSL";
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body);
SMTP -> ERROR: EHLO not accepted from server:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> ERROR: AUTH not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedThe following From address failed: [email protected] : Called Mail() without being connected Mailer Error: The following From address failed: [email protected] : Called Mail() without being connected
$mail->SMTPSecure = "tls";
$mail->Subject = "PROVA DI INVIO SSL";
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
//$body = file_get_contents('contents.html'); // testo del messaggio in formato html
//$mail->MsgHTML($body);
SMTP -> ERROR: Failed to connect to server: Connection refused (111)
The following From address failed: [email protected] : Called Mail() without being connected Mailer Error: The following From address failed: [email protected] : Called Mail() without being connected
telnet smtp.tiscali.it 25 -> connessione non riuscita
telnet smtp.tiscali.it 587 -> connessione non riuscita
telnet smtp.tiscali.it 465 -> si connette
$mail->$Encoding = 'base64';
if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP)){
// var_dump($SMTPIN); print "<br /><br />";
fputs ($SMTPIN, "HELO ".$this->HTTPhost."\r\n");
$talk["hello"]=fgets($SMTPIN, 1024);
// fputs ($SMTPIN, "STARTTLS\r\n");
// $talk["STARTTLS"]=fgets($SMTPIN, 1024);
fputs($SMTPIN, "auth login\r\n");
$talk["res"]=fgets($SMTPIN, 1024);
fputs($SMTPIN, $this->SmtpUser."\r\n"); <<<----- riga 55
$talk["user"]=fgets($SMTPIN, 1024);