PHP SMTP send mail error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
midohioit
Forum Newbie
Posts: 18
Joined: Tue Dec 05, 2006 10:19 am

PHP SMTP send mail error

Post 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?
Last edited by midohioit on Tue Jan 09, 2007 11:51 am, edited 2 times in total.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: PHP SMTP send mail error

Post 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";

?>
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

:nonono:

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

:rofl:
Post Reply