问题
Error Received:
Parse error: syntax error, unexpected '@' in C:\xampp\htdocs\FYP_v4\mailSMTP.php on line 11
I am using PHPmailer from Github. I was supposed to receive a email after running mailSTMP.php to authorize the username, but ended up receiving the error mentioned above instead. Please advise and assist. Thank you!
From mailSTMP.php,
//require_once('class.phpmailer.php');
require_once('PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = "UTF-8";
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->Username = 'username@gmail.com';
$mail->Password = 'password';
$mail->SMTPAuth = true;
$mail->From = 'username@gmail.com';
$mail->FromName = 'Mohammad Masoudian';
$mail->AddAddress('xxxxxxx@mail.com');
$mail->AddReplyTo('xxxxxxx@gmail.com', 'Information');
$mail->IsHTML(true);
$mail->Subject = "PHPMailer Test Subject via Sendmail, basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->Body = "Hello";
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
if (!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
From php.ini,
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
include_path=".;C:\xampp\php\PEAR;C:\xampp\htdocs\FYP_v4"
;
; PHP's default setting for include_path is ".;/path/to/php/pear"
; http://php.net/include-path
From sendmail.ini,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=587
; SMTPS (SSL) support
; auto = use SSL for port 465, otherwise try to use TLS
; ssl = alway use SSL
; tls = always use TLS
; none = never try to use SSL
smtp_ssl=auto
; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify
;default_domain=mydomain.com
; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging
error_logfile=error.log
; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging
;debug_logfile=debug.log
; if your smtp server requires authentication, modify the following two lines
auth_username= username@gmail.com
auth_password= password
; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines. do not enable unless it is required.
pop3_server= smtp.gmail.com
pop3_username= username@gmail.com
pop3_password= password
; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify
; the "From: " header of the message content
force_sender= username@gmail.com
; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify
; the "To: " header of the message content
force_recipient=
; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required
hostname=
来源:https://stackoverflow.com/questions/28000066/email-for-xampp-having-parse-error-syntax-error-unexpected