PDA

View Full Version : سوال: ارسال email با smtp در PHP Version 4.3.2



FirstLine
پنج شنبه 07 آبان 1388, 15:36 عصر
با سلام
یه سرور و PHP Version 4.3.2 هست
قبلا میل سرور روی همین دستگاه بوده اما الان میل سرور روی سرور دیگری قرار دارد.
کد ایمیلهایی که قبلا کار میکرد دیگه کار نمیکنه.
لطفا راهنمایی بفرمایید با توجه به اینکه PHP Version 4.3.2 داریم از چه کدی برای ارسال ایمیل استفاده کنم؟
با تشکر

FirstLine
پنج شنبه 07 آبان 1388, 15:47 عصر
کد زیر را که قرار میدهم متاسفانه هیچ پیغامی نمیدهد:


<html>
<head>
<title>PHPMailer - SMTP basic test with authentication</title>
</head>
<body>
Send email
<?php

//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');

require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer();

//$body = file_get_contents('contents.html');
//$body = eregi_replace("[\]",'',$body);

$body ="texssssssss ";

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.eghlid.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.eghlid.com"; // sets the SMTP server
$mail->Port = 26; // set the SMTP port for the GMAIL server
$mail->Username = "webmaster@eghlid.com"; // SMTP account username
$mail->Password = "123456"; // SMTP account password

$mail->SetFrom('webmaster@eghlid.com', 'First Last');

$mail->AddReplyTo("heidarnia@eghlid.com","First Last");

$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "heidarnia@eghlid.com";
$mail->AddAddress($address, "John Doe");

//$mail->AddAttachment("phpmailer.gif"); // attachment
//$mail->AddAttachment("phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

?>

</body>
</html>