編輯:不知何故代碼只適用於網絡服務器,而不是本地主機,所以有你的「修復」。PHPMailer在一個頁面上工作,但不能在類似的工作
所以,我的PHP代碼工作,因爲它應該是這樣的:
require 'PHPMailer/PHPMailerAutoload.php';
$nome = $_POST["nome"];
$subject = $_POST["subject"];
$message = $_POST["message"];
$email = $_POST["email"];
$contacto = $_POST["contacto"];
$body = "<p>Mail recebido de: </p>" . $nome . "<p>Email:</p>" . $email . "<p> Contacto:</p>" . $contacto . "<p>Mensagem:</p>" . $message ;
$mail = new PHPMailer();
$mail->CharSet = "text/html; charset=UTF-8;";
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->CharSet = 'UTF-8';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = "the email";
$mail->Password = the password;
$mail->SetFrom('the email', 'Organizer');
$mail->Subject = "[ORÇAMENTO] " . $subject;
$mail->Body = $body;
$mail->IsHTML(true);
$mail->AddAddress("the email");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
$sucesso = 'Mensagem enviada com sucesso!';
}
這第一個腳本發送電子郵件給自己,但即使沒有在這裏($ MAIL-工作>發送()= 1 ,我仍然沒有收到電子郵件):
require '../PHPMailer/PHPMailerAutoload.php';
$body = "<p>Car(a) " . ${'user' . $i} . ",</p> <p> Foi lhe associado(a) uma nova ocorrência. Consulte-a em http://www.organizer.com.pt . </p>";
$mail = new PHPMailer();
$mail->CharSet = "text/html; charset=UTF-8;";
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->CharSet = 'UTF-8';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->Username = "the email";
$mail->Password = the password;
$mail->SetFrom('the email', 'Organizer');
$mail->Subject = "Nova Ocorrência";
$mail->Body = $body;
$mail->IsHTML(true);
$mail->AddAddress($email);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
$sucesso = 'Mensagem enviada com sucesso!';
}
我已經測試了所有我從數據庫中獲取等變量,他們是正確的,我只是不接收電子郵件出於某種原因。任何人都可以幫忙
P.S .:對不起,這是用葡萄牙語,我認爲代碼仍然是完全可以理解的。
任何錯誤信息? –
nope,據說郵件被髮送,這就是爲什麼我不明白。 – Manuel
檢入腳本2 ...是否「需要」../ PHPMailer/PHPMailerAutoload.php';「或「需要'PHPMailer/PHPMailerAutoload.php';」 –