Jump to content

SMTP mail and pear mail package


sw9

Recommended Posts

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 <[email protected]>";
$to = "[email protected]";
$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 = "[email protected]";
$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>");
}

?>

Link to comment
https://forums.phpfreaks.com/topic/82336-smtp-mail-and-pear-mail-package/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.