Jump to content

[SOLVED] SMTP send email error


simple_man_11

Recommended Posts

[b]code:[/b]

<? php
$mail = new PHPMailer();

$mail->IsSMTP();                                  // send via SMTP
$mail->Host    = "localhost"; // SMTP servers
$mail->SMTPAuth = true;    // turn on SMTP authentication
$mail->Username = "[email protected]";  // SMTP username
$mail->Password = "******"; // SMTP password

$mail->From    = "[email protected]";
$mail->FromName = "Mailer";
$mail->AddAddress("[email protected]","Josh Adams");
$mail->AddAddress("[email protected]","test");              // optional name
$mail->AddReplyTo("[email protected]","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";

?>

[b]Error displayed on the page:[/b]

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?
Link to comment
https://forums.phpfreaks.com/topic/33492-solved-smtp-send-email-error/
Share on other sites

maybe you just left it out of what you posted, but it doesn't look live you've included the page that has the PHPMailer() class functions.

line two tries to create a new instance of PHPMailer but since you haven't included the class, it doesn't know what PHPMailer is.

you need to add something like:

include('whatever_the_filename_is.class.php');

before line 2

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.