Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/05/2008, 20:35
Avatar de trasgukabi
trasgukabi
 
Fecha de Ingreso: septiembre-2004
Mensajes: 2.749
Antigüedad: 22 años, 1 mes
Puntos: 18
Re: Conectar a sevidor smtp

Código PHP:
<?php
require_once "Mail.php";

$from = "Sandra Sender <[email protected]>";
$to = "Ramona Recipient <[email protected]>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";

$headers = array ('From' => $from,
  
'To' => $to,
  
'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array (
'host' => $host,
    
'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>");
 }
?>