errors with mail

the mail() function

Moderators: macek, egami, gesf

Danish05301
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Mar 08, 2012 11:26 pm

errors with mail

Postby Danish05301 » Thu Mar 08, 2012 11:47 pm

I am new to php and am trying to get emails sent out through smpt. I am using a simple sample program as shown(information in caps is my actual information):

Code: Select all

<?php
 require_once 'Mail.php';
 
 $from = "Sandra Sender <MYEMAILISHERE>";
 $to = "Ramona Recipient <ANOTHEREMAILACCOUNTHERE>";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";
 
 $host = "mail.MYEMAIL";
 $username = "MYLOGINSTUFF";
 $password = "MYLOGINPASSWORD";
 
 $headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
 $smtp = Mail::factory('smtp',
   array ('host' => $host,
     '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>");
  }
 ?>


what I get is

Warning: include_once(Net/SMTP.php) [function.include-once]: failed to open stream: No such file or directory in /usr/local/lib/php/Mail/smtp.php on line 348

Warning: include_once() [function.include]: Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /usr/local/lib/php/Mail/smtp.php on line 348

Fatal error: Class 'Net_SMTP' not found in /usr/local/lib/php/Mail/smtp.php on line 349

from what I can tell this means that my SMTP.php file is in the wrong directory. I installed PEAR and I installed the mail fuction which comes with the NET_SMTP and NET_SOCKET through the cpanel so I would imagine that is all correct. When looking at the file structure it is as follows:
-PHP
--mail.php
---mail
----all the .php mail files
--net
---all the .php net files
(sorry for the ascii hierarchy)

I located where it calls the net/smtp.php on line 348 in the smtp.php file and traced it back and the file is there and should be able to be opened. The access restrictions are not a problem since they are 0644(read only for the world).

Anyone have any ideas what I'm doing wrong. I'm fairly new to .php however everything I looked up said that my mail function was not installed correctly. I can't see a problem with the installation and I hardly think that cpanel would have installed it wrong.

Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 0 guests

cron