I'm facing the below exception
Failed to connect to smtpout.asia.secureserver.net:465 [SMTP: Invalid
response code received from server (code: -1, response: )]
I'm using PHP 7.1.12-3+ubuntu14.04.1+deb.sury.org+1 (cli) and PEAR Version: 1.10.5.
Here's my PHP code:
<?php
try {
require_once "Mail.php";
$from = "support#domain.com";
$to = "user#gmail.com";
$subject = "Testing email please ignore";
$message = "Just testing";
$host = "smtpout.asia.secureserver.net";
$port = 465;
$username = "support#domain.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, $message);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
} catch(Exception $e) {
echo $e;
}
?>
Do I need to change any settings in Godaddy?
If you are using their(Godaddy) email address,SMTP_SERVER should be localhost.
If you are using google server to send the emails change SMTP_SERVER accordingly.
hope this helps
$host: "localhost" //use godaddy server as smtp
Related
Using code similar to below: On my server side I get an error that seems to imply it is trying use a certificate rather than the user/pass I'm providing (also below). Anyone else seen that, and have you gotten it to work? I've tried googling the error but I seem to just get a bunch of irrelevant results. Linux/PHP7.2.5 (also fails on PHP5.4.20) BUT seems to work just fine under Windows/PHP7
SSL_accept error from mail.XXXXXX.com[xxx.xxx.xxx.xxx]: 0
warning: TLS library problem: 20353:error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca:s3_pkt.c:1293:SSL alert number 48:
<?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";
$username = "smtp_username";
$password = "smtp_password";
$port = 465;
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => 'PLAIN',
'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>");
}
?>
The relevant part of the error message is
unknown ca
which means "certificate is signed by an unknown certificate authority".
Check if the root CA list is up to date on the machine.
I have a server and trying to send email using Pear and SMTP. Here is my code:
<?php
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED ^ E_STRICT);
ini_set("include_path", '/home/example/php:' . ini_get("include_path") );
require_once "Mail.php";
$host = "ssl://mail.example.com";
$username = "info#example.com";
$password = "ABC#123";
$port = "465";
$to = "mymail#gmail.com";
$email_from = "info#example.com";
$email_subject = "Subject Line Here: " ;
$email_body = "whatever you like" ;
$email_address = "noreply#example.com";
$headers = array ('From' => $email_from, 'To' => $to, 'Subject' => $email_subject, 'Reply-To' => $email_address);
$smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password));
$mail = $smtp->send($to, $headers, $email_body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
Pear Library are installed and path is correct. But when I run the code. Getting this error:
Failed to connect to ssl://mail.example.com:465 [SMTP: Failed to
connect socket: fsockopen(): unable to connect to
ssl://mail.example.com:465 (Unknown error) (code: -1, response: )]
Don't know where is the issue. openssl_dl is enable. Port is also open at TCP_IN. Is any issue with the ssl. Is it requred to install on my domain name or hostname. If yes then please let me know how to do it.
My page php code is this
`
require_once "Mail.php";
$from = "<pramodkumar.damam73#gmail.com>";
$to = "<pramodkumar.damam73#gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "pramodkumar.damam73#gmail.com"; //<> give errors
$password = "mypassword";
$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>");
}
?>`
Initially it shown many errors saying isError and send functions are not static. So I modified PEAR.php and Mail.php's functions as static. But now I am getting error like
Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (code: -1, response: )]
Please fix my problem.
I'm trying to figure out how send email from php using google's SMTP servers, but change the FROM header to match my domain. The email sends fine, but the recipient sees it sent from myemail#gmail.com, rather than me#mydomain.com. I'm using php pear mail to send.
require_once("Mail.php");
$from = "Me <me#mydomain.com>";
$to = "Zach <myemail#gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "smtp.gmail.com";
$username = "****";
$password = "****";
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
You must set a ssl encryption. Google can help you http://www.google.com/search?q=pear+mail+ssl
I'm having endless trouble while trying to send mail using the pear mail package:
I'm using xampp on my local machine for testing purposes and the following code works perfectly:
//PEAR
require_once('../PEAR/Mail.php');
$from = "<sender#domain.com>";
$to = "<receiver#domain.com>";
$subject = "Hi";
$body = "Testing message";
$host = "ssl://smtp.gmail.com"; //ssl://
$port = "465";
$username = "my_account#gmail.com";
$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);
function &factory($driver, $params = array())
{
$driver = strtolower($driver);
#include_once 'Mail/' . $driver . '.php';
$class = 'Mail_' . $driver;
if (class_exists($class)) {
$mailer = new $class($params);
return $mailer;
} else {
return PEAR::raiseError('Unable to find class for driver ' . $driver);
}
}
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
//end of php tag
HOWEVER, when I upload the file to the online web server and run the exact same script I receive the following error:
"Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: Connection refused (code: -1, response: )]"
I have also tried ports 587 and 443 to no avail. I'm guessing the problem must lie with either socket.php, smtp.php, mail.php or even with the server config files since there seems to be nothing wrong with the above code. I would be extremely grateful if someone could point me in the right direction!
Ya because your host may not support ssl connection.
Ask your host for php_openssl support. Or either you can manually try the following to load dll.
if(dl(php_openssl.so))
or
if(dl(php_openssl.dll))
this is general error because of extension=php_openssl.dll file is not uncommented on server.
Connection is refused by Google because you need to specify the "localhost" parameter in "Mail::factory" call as shown in the code below:
$host = "ssl://smtp.gmail.com"; //ssl://
$port = "465";
$username = "my_account#gmail.com";
$password = "**********";
$localhostname = gethostname();
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'localhost' => $localhostname,
'username' => $username,
'password' => $password));
Then the email should go through just fine! I have encountered hosting providers where it wasn't necessary to provide the "localhost" parameter but with others it seems to be required even though the official PEAR documentation lists it as optional...