這裏是我的代碼,我想通過PHP發送電子郵件。
這是我的代碼,但郵件功能無法正常工作。它顯示錯誤:郵件程序錯誤無法實例化郵件功能。php郵件不發送郵件。代碼中可能有錯誤?
<?php
require_once('PHPMailer/class.phpmailer.php');
$frompage= $_REQUEST['frompage'];
if($frompage=="contact"){
$mname= $_REQUEST['mname'];
$mmobile= $_REQUEST['mmobile'];
$memail= $_REQUEST['memail'];
$gemail= str_replace("atsymbol","@",$memail);
$mcomment= $_REQUEST['mcomment'];
$body = file_get_contents('email-template.html');
$body = eregi_replace("<mfrompage>" , $frompage, $body);
$body = eregi_replace("<mname>" , $mname, $body);
$body = eregi_replace("<mmobile>" , $mmobile, $body);
$body = eregi_replace("<memail>" , $gemail, $body);
$body = eregi_replace("<mcomment>" , $mcomment, $body);
}
if($frompage=="career"){
$mname= $_REQUEST['mname'];
$mmobile= $_REQUEST['mmobile'];
$memail= $_REQUEST['memail'];
$gemail= str_replace("atsymbol","@",$memail);
$mcomment= $_REQUEST['mcomment'];
$body = file_get_contents('email-template2.html');
$body = eregi_replace("<mfrompage>" , $frompage, $body);
$body = eregi_replace("<mname>" , $mname, $body);
$body = eregi_replace("<mmobile>" , $mmobile, $body);
$body = eregi_replace("<memail>" , $gemail, $body);
$body = eregi_replace("<mcomment>" , $mcomment, $body);
}
$mail = new PHPMailer(); // defaults to using php "mail()"
$mail->AddReplyTo($gemail,$mname);
$mail->SetFrom($gemail,$mname);
$address = "[email protected]"; //where email need to be sent
$mail->AddAddress($address);
// $mail->AddCC("[email protected]", "[email protected]");
$mail->Subject = "Query from website Vermillion.net.in";
//$mail->AltBody = "This is for text based email"; // optional
//$mail->Body=$body;
$mail->MsgHTML($body);
// $mail->AddAttachment("images/phpmailer.gif"); // attachment
// $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent sucessfully!";
}
?>
這是我的代碼,但郵件功能無法正常工作。它顯示錯誤:郵件程序錯誤無法實例化郵件功能。
它已經有一段時間在香港專業教育學院看到行動'ereg'。在5.3中沒有貶值嗎? –