Click here to Skip to main content
15,921,179 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need the function to mail some data through php from my website, so i am trying an example to know how. but it is not working. as it needs authentication i am using phpmailer, but it is not working.
this is the code.

<?require("path\phpmailer.php");
$mail = new PHPMailer(); 
$mail->IsSMTP();
$mail->Host = "smtp.example.com";
$mail->SMTPAuth = true;
$mail->Username = "usernamexxx";
$mail->Password = "password"; 
$mail->From = "xxxxxx@example.com";
$mail->FromName = "Name";
$mail->AddReplyTo("name@example.com");$mail->AddAddress("name@example.com");
$mail->IsHTML(true);$mail->Subject = "Test message sent using the PHPMailer component";
$mail->Body = "This is a test message.";$mail->Send();
?>


this is the error:

Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\test.php on line 3



Please help


[edit]Urgency deleted - OriginalGriff[/edit]
Posted
Updated 5-Oct-11 1:25am
v4
Comments
OriginalGriff 5-Oct-11 7:16am    
Urgency deleted: It may be urgent to you, but it isn't to us. All that your stressing the urgency does is to make us think you have left it too late, and want us to do it for you. This annoys some people, and can slow a response.
Yuri Vital 5-Oct-11 7:22am    
1°) Why this QA is C# related ? I see Only PHP code :)

2°) What you found at line 3 in "C:\xampp\htdocs\test.php" ?
adnama 5-Oct-11 7:26am    
"C:\xampp\htdocs\test.php" that is the actual class that i am trying to send email from
Yuri Vital 5-Oct-11 7:41am    
It was long time ago that i did PHP, but a linefeed or spacing is not needed after the ?> element ?
ie :
<?
require("path\phpmailer.php");

is there a method (or function to PHP people) in the PHPMailer class called IsSMTP();?

By the naming it sounds more like a property that you would assign a value to, but I can't be sure as I don't know PHPMailer.

Given that further on you seem to call a similarly-named method:

$mail->IsHTML(true);


You might want to pass a boolean to IsSMTP();:

$mail->IsSMTP(true);
 
Share this answer
 
Try this, should work

Assumption

***YOUR PHPMAILER is in a folder (PHPmailer) and copied into your current directory

<?php
require_once('PHPMailer/class.phpmailer.php'); 
$mail = new PHPMailer(); 
$mail->SMTPDebug = 1;
$mail->IsSMTP();
$mail->Host = "10.10.27.7";
$mail->Username = "bala@*****.co.uk";
$mail->Password = "******"; 
$mail->SMTPAuth = true;
$mail->From = "bala@*******.co.uk";
$mail->FromName = "test";
$mail->AddReplyTo("bala@******.co.uk");
$mail->AddAddress("bala@*****.co.uk");
$mail->IsHTML(true);
$mail->Subject = "Test message sent using the PHPMailer component";
$mail->Body = "This is a test message.";
$mail->Send();
?>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900