User Tools

Site Tools


informatica:linux:php:mail

This is an old revision of the document!


Instalamos paquetes necesarios de PEAR. Yo he instalado: php-mail, php5-dev, php-net-mail, php-net-smtp.

<?php 
require_once "Mail.php";

$from = "Ose <lobo99@lobo99.info>"; 
$to = "Jose <jlegido@mailext.com>"; 
$subject = "Hi!"; 
$body = "Hi,\n\nHow are you?";

$host = "smtp.jazztel.es"; 
$username = "lobo99.lobo99.jazztel.es"; 
$password = "lobo99";

$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>"); 
} 
?>
informatica/linux/php/mail.1194218484.txt.gz · Last modified: 2015/04/13 20:19 (external edit)