php mailer parse error

北城以北 提交于 2019-12-13 05:09:03

问题


I have a site that is hosted on inmotion hosting and requires a phpMailer in order to send an email form (such as a contact form) from a site. I've put the necessary files and code on the contact page, but I am getting a parse error once I hit submit. Here's the error message:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/username/public_html/phpmailer/class.phpmailer.php on line 53

Line 53 according to DreamWeaver is

public $Priority          = 3;

Does anyone know why I might be getting a parse error?


回答1:


Server PHP version problem. This error occurs when a web server is running an older version of PHP (probably php4) and the phpmailer version you've download is for PHP5. Only your web hosting company can upgrade PHP to the new version.

option 1: Download phpmailer for PHP4: link here. Then Rename (or delete) the phpmailer you've got now and replace it with the php4 version.

option 2: Change web hosting providers to one offering more modern accommodations.

good luck!

ps. Once you've decided to accept an answer, click the "check" to the left of this box to let the community know your problem has been addressed.




回答2:


if you created your code from this example

http://phpmailer.worxware.com/index.php?pg=exampleasmtp

you are using version 5 or above.

If your version of php mailer doesn't work because of php version, download the phpmailer version 2.0.4 from the link

http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php4/PHPMailer%20v2.0.4%20for%20PHP4/

(thanks Mr. jpwco) and change the lines

$mail->SetFrom('name@yourdomain.com', 'First Last');

to

`$mail->From ='example@yahoo.com';

$mail->FromName = 'John Dorian';

and it will work.

By the way, if you are going to use a yahoo acount for smtp mail use

$mail->SMTPSecure = "ssl";

$mail->Host = "smtp.mail.yahoo.com"; $mail->Port = 465;

$mail->Username = "mail_adress@yahoo.com";
$mail->Password = "password";

It took me like an hour to figure it out!



来源:https://stackoverflow.com/questions/4752889/php-mailer-parse-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!