What is wrong with this code

the mail() function

Moderators: macek, egami, gesf

edtrudee
New php-forum User
New php-forum User
Posts: 1
Joined: Thu Dec 29, 2011 3:50 pm

What is wrong with this code

Postby edtrudee » Thu Dec 29, 2011 3:52 pm

<?php

require_once "Mail.php";

$from = "<from.gmail.com>";
$to = "<to.yahoo.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "<myaccount.gmail.com>";
$password = "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>");
}

?>


ANd does this code have to be inline ? or would you name this the mail.php?

User avatar
bigjoe11a
New php-forum User
New php-forum User
Posts: 137
Joined: Wed Aug 31, 2011 3:55 am
Location: USA
Contact:

Re: What is wrong with this code

Postby bigjoe11a » Sun Jan 29, 2012 6:48 pm

Well I don't know any thing about mail factory. You mite want to try phpmailer. I use it all the time my self. Or you will have to wait for some one that knows some thing about mail factory.

Joe


Return to “PHP coding => Mail”

Who is online

Users browsing this forum: No registered users and 1 guest

cron