0

Guys, need help again, I cant get my mail script working...

here is my code

<?php
 require_once "Mail.php";
 
 $from = "Sandra Sender <sender@example.com>";
 $to = "Ramona Recipient <recipient@example.com>";
 $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>");
  }
 ?>

im working on a linux server...is there something i need to install?

thank you guys!!!

4
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by jcarbillon
0

You got this example from SO ? It is designed to work with gmail, so change your sender email addresses and username and password. I am assuming you already have PEAR installed.

Edited by pritaeas: n/a

0

The first argument to this function is the recipient, the second specifies the message's subject and the third one should contain the body. So to send a simple sample message, we could use:

<?php
$to = "recipient@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>

Edited by happygeek: Fake sig snipped

0

@pritaeas - my pear is working , still no luck.. i google some alternative for this and I found the phpmailer and it works.... but still i want this to pursue this using pear..

@ppt123 - ill try ur suggestion


thank you guys

0

@zero13 - thanks for the reminder

@pritaeas - thanks! I will give it a try

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.