Page 1 of 1

PHP SMTP send mail error

Posted: Tue Jan 09, 2007 11:43 am
by midohioit
code:

Code: Select all

<?php
$mail = new PHPMailer();

$mail->IsSMTP();                                   // send via SMTP
$mail->Host     = "localhost"; // SMTP servers
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "webmaster@thesmileshack.com";  // SMTP username
$mail->Password = "******"; // SMTP password 

$mail->From     = "webmaster@thesmileshack.com";
$mail->FromName = "Mailer";
$mail->AddAddress("charles@midohioit.com","Josh Adams"); 
$mail->AddAddress("chadamywilson@alltel.net","test");               // optional name
$mail->AddReplyTo("info@site.com","Information");

$mail->WordWrap = 50;                              // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz");      // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); 
$mail->IsHTML(true);                               // send as HTML

$mail->Subject  =  "Here is the subject";
$mail->Body     =  "This is the <b>HTML body</b>";
$mail->AltBody  =  "This is the text-only body";

if(!$mail->Send())
{
   echo "Message was not sent <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";

?>
Error displayed on the page:

Parse error: syntax error, unexpected T_VARIABLE in /home/thesmi6/public_html/form/phpmailer/phpmailer/mail.php on line 2


Could someone tell me why I am getting this error?

Re: PHP SMTP send mail error

Posted: Tue Jan 09, 2007 11:46 am
by volka
midohioit wrote:<? php
remove the blank between <? and php

and plase use

Code: Select all

tags when posting php code

Code: Select all

<?php
$mail = new PHPMailer();

$mail->IsSMTP(); // send via SMTP
$mail->Host = "localhost"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "webmaster@thesmileshack.com"; // SMTP username
$mail->Password = "******"; // SMTP password

$mail->From = "webmaster@thesmileshack.com";
$mail->FromName = "Mailer";
$mail->AddAddress("charles@midohioit.com","Josh Adams");
$mail->AddAddress("chadamywilson@alltel.net","test"); // optional name
$mail->AddReplyTo("info@site.com","Information");

$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
$mail->IsHTML(true); // send as HTML

$mail->Subject = "Here is the subject";
$mail->Body = "This is the <b>HTML body</b>";
$mail->AltBody = "This is the text-only body";

if(!$mail->Send())
{
	echo "Message was not sent <p>";
	echo "Mailer Error: " . $mail->ErrorInfo;
	exit;
}

echo "Message has been sent";

?>

Posted: Tue Jan 09, 2007 12:12 pm
by Kieran Huggins
:nonono:

he meant remove the space in your script, not in your question.

:rofl: