ev5unleash Posted May 8, 2012 Share Posted May 8, 2012 Hi All, I'm in the process of learning PHP and I don't know everything so please bare with me. I'm trying to have a simple e-mail script which will send a nice e-mails with variables from a previous form. I don't want to use my PHP servers predefined e-mail settings but define them myself. I plan on using G-Mail's SSL SMTP protocol. Upon looking up scripts for e-mailing I'm always coming across require_once "Mail.php"; in the code with no explanation on where that file is located. I'm currently using this code for to see if it works: <?php require_once "Mail.php"; $from = "Sandra Sender <[email protected]>"; $to = "Ramona Recipient <[email protected]>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "ssl://mail.example.com"; $port = "465"; $username = "smtp_username"; $password = "smtp_password"; $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 I get the error Fatal error: Class 'Mail' not found in C:\wamp\www\Quiz\sendmail.php on line 16 If anyone could be so kind to give me an explanation and assist me in understanding, that'd be great. Thanks, Evan Quote Link to comment https://forums.phpfreaks.com/topic/262256-simple-mail-implementation/ Share on other sites More sharing options...
Muddy_Funster Posted May 8, 2012 Share Posted May 8, 2012 you haven't created an instance of the mail class. you need to do something like $Mail = new Mail(); and then you can call $Mail::factory('smtp') I havn't used this Mail that you're using so can't say more than that really. Quote Link to comment https://forums.phpfreaks.com/topic/262256-simple-mail-implementation/#findComment-1343989 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.