Jump to content

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 <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>");
}

?>

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.