sw9 Posted December 19, 2007 Share Posted December 19, 2007 I have Marc Liyanage's PHP 5.2 package installed on my Mac OS X Tiger computer. I am trying to send mail using php mail function, but many of the addresses bounce it back because it's seeing the host as mycomputer.local. So I'm trying to integrate smtp and all that jazz. However, now I'm getting an error that it can't find the mail.php include. I found this snippet to use, so I am not sure where this mail file exists on the mac...Can anyone help me with how I can best go about this? Here is my script. <?php require_once "Mail.php"; //change this to your email. $theVar = file_get_contents('/file'); $theSub = file_get_contents('/file3'); $from = "Me <me@me.com>"; $to = "be@somebody.com"; $subject = "Link for ".$theSub; $message = "<html><body bgcolor=\"#DCEEFC\"><br><br><b>Here is the link you need to paste into the website:</b> <br><br><br><a href=\"". $theVar."\">".$theVar."</a></body> </html>"; $host = "smtp.gmail.com"; $port = "587"; $username = "me@gmail.com"; $password = "mypass"; $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>"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/82336-smtp-mail-and-pear-mail-package/ 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.