这里是我的代码,我想通过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中没有贬值吗? –