-1

I want to send mail using PHPMailer.

I have download phpmailer class form github and I included PHPMailerAutoload.php file to my index.php file.

<?php
require_once('libs/PHPMailer/PHPMailerAutoload.php');

$m = new PHPMailer;

$m->isSMTP();
$m->SMTPAuth = true;
$m->SMTPDebug = 2;

$m->Host = 'smtp.gmail.com';
$m->username = 'manish@example.com';
$m->password = 'example_!@#4';
$m->SMTPSecure = 'ssl';
$m->Port = 465;

$m->From='manish@example.com';
$m->FromName='Manish';
$m->addReplyTo('manish@example.com','Reply Address');
$m->addAddress('manish@example.com','Manish Address');

$m->Subject = 'Here is an Email';
$m->body = 'This is body';
$m->AltBody = 'This is the body osf email';

var_dump($m->send());
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
Manish Tiwari
  • 1,806
  • 10
  • 42
  • 65

2 Answers2

0

Change the following line

$m->IsSmtp();

with

$m->IsMail();
or 
$m->IsSendmail();
Keyur Mistry
  • 926
  • 6
  • 18
-1

Include I more file and I edited your code please check

require_once('libs/PHPMailer/PHPMailerAutoload.php');
require 'libs/PHPMailer/class.phpmailer.php';
$m = new PHPMailer;

$m->isSMTP();
$m->SMTPAuth = true;

$m->Host = 'smtp.gmail.com';
$m->Username = 'manish@example.com';
$m->Password = 'example_!@#4';
$m->SMTPSecure = 'ssl';
$m->Port = 465;

$m->setFrom('manish@example.com', 'Manish');
$m->AddReplyTo('manish@example.com','Reply Address');
$m->AddAddress('manish@example.com','Manish Address');

$m->Subject = 'Here is an Email';
$m->Body = 'This is body';
$m->AltBody = 'This is the body osf email';

var_dump($m->send());
Sudhir
  • 835
  • 11
  • 31
  • it give an error syntax error, unexpected ',' in C:\xampp\htdocs\phpmailer\index.php on line 16 and on line 16 code is setFrom – Manish Tiwari Jan 21 '16 at 11:09
  • Don't do this. It's wrong. Use the examples provided with PHPMailer. Changing code randomly is not an effective way of debugging. – Synchro Jan 21 '16 at 14:27