我有這個工作,我不知道我做了什麼,使它停止。這裏是我的電子郵件類:電子郵件類PHP停止工作
<?php
// File Details: Base mail class
class Email {
private $to = '[email protected]';
public $email = NULL;
public $phone = NULL;
public $subject = NULL;
public $body = NULL;
//private $magic_quotes_active;
// private $real_escape_string_exists;
//function __construct() {
//$this->magic_quotes_active = get_magic_quotes_gpc();
//$this->real_escape_string_exists = function_exists("mysql_real_escape_string");
//}
public function send() {
$this->addHeader('From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n");
$this->addHeader("MIME-Version: 1.0\r\n");
$this->addHeader("Content-Type: text/html; charset=ISO-8859-1\r\n");
$success = mail($this->to, $this->subject, $this->body, $this->headers);
if ($success) {
return true;
} else {
return false;
}
}
private function addHeader($header) {
$this->headers .= $header;
}
public function setName($first, $last) {
$this->first = $first;
$this->last = $last;
}
public function setSubject($subject) {
$this->subject = $subject;
}
public function setPhone($phone) {
$this->phone = $phone;
}
public function setEmail($email) {
$this->email = $email;
}
public function setBody($body) {
//$this->body = $this->escape_value($body);
$this->body = $body;
}
//public function escape_value($value) {
// if ($this->real_escape_string_exists) { // PHP 4.3.0 or higher
// // undo any magic quote effects so mysql_real_escape_string can do the work
// if ($this->magic_quotes_active) {
// $value = stripslashes($value);
// }
// $value = mysql_real_escape_string($value);
//
// } else { // before PHP v.4.3.0
// //if magic quotes aren't already on then add slashes manually
// if (!$magic_quotes_active) {
// $value = addslashes($value);
// }
// }
//
// return $test;
// }
}
$mail = new Email();
$mail->setSubject($_POST['subject']);
$mail->setBody($_POST['body']);
$mail->setName($_POST['first'], $_POST['last']);
$mail->setEmail($_POST['email']);
$mail->setPhone($_POST['phone']);
$mail->send();
?>
在這裏,我稱之爲:
$mail = new Email();
$mail->setName($_POST['first'], $_POST['last']);
$mail->setSubject($_POST['subject']);
$mail->setBody($_POST['body']);
$mail->setEmail($_POST['email']);
$mail->setPhone($_POST['phone']);
$mail->send();
我必須在腳本的頂部,一旦需要的類和我沒有得到任何時候PHP錯誤我運行它。當我回顯$mail->send();
它回來是真實的。所以有人可以幫助我理解這裏發生的事情(或者爲什麼事情不再發生,更確切地說)。電子郵件永遠不會來。
感謝今天大家的幫助,順便說一句。
的PHPMailer也允許登錄通過SMTP,這使得它讓你的主機上的實際的,有效的電子郵件帳戶被分派郵件。如果許多配置較好的郵件服務器在源主機中不代表有效的用戶,它們將拒絕郵件中包含的郵件和回覆郵件頭。例如,Gmail在確定垃圾郵件時也會執行此操作並檢查有效的SPF記錄。 – DeaconDesperado 2010-12-14 23:08:44