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.
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'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
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.
I have an existing email.PHP that sends emails based on certain functions with in my website, similar to forum notifications.
However its very hit n miss with sending them, worked well for two days then just stopped.
My question is is there a simple way to add smtp instructions to the existing script so that it will use Gmail rather than PHP mail()
I can supply current script if required.
Thanks in advance.
You need to install PEAR Mail. Then you can do it like this.
<?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"; //<> give errors
$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'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