i am using the pear mail package to send an email.
it is for a new client of mine so any help is greatly appreciated [=
this is the error i get
Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: Permission denied (code: -1, response: )]
i have installed pear mail and NET_SMTP and am using a new version of php.
i recently used the class.phpmailer.php on windows and it worked fine. But on my vps it is giving me the same error.
the code i am trying to use for this class is as follows
This code above produces this error message
SMTP -> ERROR: Failed to connect to server: Permission denied (13)
SMTP Error: Could not connect to SMTP host.
I know the code works because i ran it off of XAMP on windows.
I am no longer testing code on my windows os. Right now i am testing my code on centos 6 32 bit.
my vps is centos 5 32 bit.
i am using apache. I think the problem may be because of the config file.
it is for a new client of mine so any help is greatly appreciated [=
this is the error i get
Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: Permission denied (code: -1, response: )]
require_once "Mail.php";
$from = "<from.gmail.com>";
$to = "<to.gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "username@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>");
}
i have installed pear mail and NET_SMTP and am using a new version of php.
i recently used the class.phpmailer.php on windows and it worked fine. But on my vps it is giving me the same error.
the code i am trying to use for this class is as follows
require_once('../sitelib/mail/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "user@gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->AddAddress('address@gmail.com', 'John Doe');
$mail->SetFrom('me@gmail.com', 'First Last');
$mail->AddReplyTo('me@gmail.com', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
$mail->MsgHTML('<b>hello world</b>');
$mail->Send();
echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
This code above produces this error message
SMTP -> ERROR: Failed to connect to server: Permission denied (13)
SMTP Error: Could not connect to SMTP host.
I know the code works because i ran it off of XAMP on windows.
I am no longer testing code on my windows os. Right now i am testing my code on centos 6 32 bit.
my vps is centos 5 32 bit.
i am using apache. I think the problem may be because of the config file.