uluru75 Posted July 31, 2008 Share Posted July 31, 2008 Hi, I have the code: $from = "Sandra Sender <[email protected]>"; $to = "Ramona Recipient <[email protected]>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "smtp.mysite.com"; $username = "myusername"; $password = "123456"; $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>"); } So, first i get this error: Fatal error: Class 'Mail' not found in .... Whenever i include "require_once 'Mail.php';" then it is not found, which make sense. what should i do to be able to send emails? How can i get a source code of Mail.php unless is not needed. Thanks, Link to comment https://forums.phpfreaks.com/topic/117495-how-to-send-email-using-smtp-authentication/ Share on other sites More sharing options...
webref.eu Posted July 31, 2008 Share Posted July 31, 2008 Hi. I am new to php so excuse me if my answer isn't that helpful, but it looks to me like this line: $smtp = Mail::factory is invoking a particular Mail class that your script doesn't have access to. The rest of the code mentions PEAR, so maybe the script is making use of component code and these guys: http://pear.php.net/ will be able to help you. Rgds Link to comment https://forums.phpfreaks.com/topic/117495-how-to-send-email-using-smtp-authentication/#findComment-604505 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.