Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Dear sir
I am new in php.
I want to sent a mail using SMTP Authentication by host, Username,Password
and want to sent mail on my domain emailID,



i am using folling code

PHP
<?php
require_once "Mail.php";
 $from = "jitendragupta1040@gmail.com";
 $to = "nitin.nammdev@osmoindia.com,jitendra.gupta@osmoindia.com";
 // $subject = $_POST['vname'];
 // $body= $_POST['vemail'];
  $subject = "hi";
  $body= "Hello";
  $host = "smtpcorp.com";
  $username = "rahul.gupta@osmoindia.com";
  $password = "mypassword";
  $port = "587";
  $headers = array ('From' => $from,   'To' => $to,   'Subject' => $subject);
  $smtp = & Mail :: factory('smtp',   array ('host' => $host,  'port' => $port,   'auth' => true,     'username' => $username,     'password' => $password));
  $mail = $smtp->send($to, $headers, $body);
  if (PEAR::isError($mail)) {   echo("<p>" . $mail->getMessage() . "</p>");  } else {   echo("<p>Message successfully sent!</p>");  }
  ?>



but it giving following error
Fatal error: Class 'Mail' not found in /home/securenet/Sent/1/Mail.php on line 14

please help to sent email.

thankyou advance.
Posted
Updated 6-Feb-15 2:25am
v2
Comments
ZurdoDev 6-Feb-15 8:32am    
The error says that the Mail class that you are trying to use is not in Mail.php. I think you need to look at Mail.php and see what the class is named.
osmo33 6-Feb-15 8:38am    
sir in my directory having only 1 file name Mail.php. then how can it miss...
please if you have better code to sent mail using SMTP Authentication sent me.
ZurdoDev 6-Feb-15 8:41am    
No, the error says there is no class named Mail in that file. Open the file and look. I don't do php but it's my understanding that the file name does not have to be the same as the class name. So, open it up. The error is very clear.

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