PHPMailer发布php版本

时间:2015-12-29 05:30:22

标签: php smtp phpmailer sendmail

我正在寻找phpmailer的帮助。我在php 5.5.12中使用这个脚本。

<?php
header ( 'Content-Type: text/html; charset=utf-8' );
require 'PHPMailer/PHPMailerAutoload.php';

$mail = new PHPMailer(true);
$mail->CharSet = 'UTF-8';
$mail->ContentType = 'text/plain';
$mail->isHTML(false); 

$master = htmlspecialchars(trim($_POST['master']));
$name = htmlspecialchars(trim($_POST['name']));
$address = htmlspecialchars(trim($_POST['address']));
$telephone = htmlspecialchars(trim($_POST['telephone']));
$question = htmlspecialchars(trim($_POST['question'], " "));
$email = htmlspecialchars(trim($_POST['email']));

$mail->isSMTP();
$mail->Host = '/*here is my host name*/';
$mail->SMTPAuth = true;
$mail->Username = '/*here is my mail*/';
$mail->Password = '/*mypassword*/';
$mail->SMTPSecure = 'auto';
$mail->Port = '25';


$mail->From = 'example@mail.ru';
$mail->FromName = $name;
$mail->addAddress('receiver@gmail.com');

$mail->Subject = 'Subject';
$mail->Body    = "$master\n$name\n$address\n$telephone\n$email\n$question";
$dateposted = date("d.m.Y");

if(!$mail->send()) {
    echo 'Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent!';
    $content = "$master\n
$name\n
$address\n
$telephone\n
$email\n
$question";
    $fp = fopen($_SERVER['DOCUMENT_ROOT'] .'/meeting_email/' . "$dateposted" . "_" . $email . '.txt',"wb");
    fwrite($fp,$content);
    fclose($fp);
}

它可以工作,但当我尝试在我的旧服务器上使用它与php 4.3.4。我有这个错误:

  

致命错误:无法在第5行的d:\ sites \ www \ record_tech \ sender.php中实例化不存在的类:phpmailer   我认为PHPMailer不支持旧的PHP版本,我试图使用PHPMailer 2.3。

我已经取代&#34;要求&#34;要求&#34; phpmailer1 / class.phpmailer.php&#39;;&#34;

因为没有PHPMailerAutoload,但我还有另一个错误:

  

解析错误:解析错误,意外T_STRING,期待T_OLD_FUNCTION或T_FUNCTION或T_VAR或&#39;}&#39;在第45行的d:\ sites \ www \ record_tech \ phpmailer1 \ class.phpmailer.php

     

致命错误:无法在第5行的d:\ sites \ www \ record_tech \ sender.php中实例化不存在的类:phpmailer   我无法将此服务器更新为php 5,并且必须在php4上解决此问题。

0 个答案:

没有答案