========================================
============================================
yum install php-pear
or
yum install php-pear-Net-SMTP
pear install Net_SMTP
pear install mail
/sbin/service httpd start
/sbin/service mysqld start
or download by wget....
# cd /tmp
# wget http://download.pear.php.net/package/Mail-1.1.14.tgz
# wget http://download.pear.php.net/package/Net_SMTP-1.2.10.tgz
# http://download.pear.php.net/package/Net_Socket-1.0.8.tgz
=================================
=== script to send mail =========
=================================
vi mail.php
<?php
require_once "Mail.php";
$from = "Tayab Sender <xyz@domain.com>";
$to = "Recipient-Khan <abc@yahoo.com>";
$subject = "Hi!";
$body = "Hi,\n\nMy Test Mail";
$host = "smtp.domain.com";
$username = "user@domain.com";
$password = "passwordofuser";
$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>");
echo "<br> Test";
} else {
echo("<p>Message successfully sent!</p>");
}
=================
php mail.php
============================
If any TLS error like "lost connection after STARTTLS"
then stop tls from server...
vi /usr/share/pear/Net/SMTP.php
public function auth($uid, $pwd , $method = '', $tls = true, $authz = '')
to
public function auth($uid, $pwd , $method = '', $tls = false, $authz = '')
If any TLS error like "lost connection after STARTTLS"
then stop tls from server...
vi /usr/share/pear/Net/SMTP.php
public function auth($uid, $pwd , $method = '', $tls = true, $authz = '')
to
public function auth($uid, $pwd , $method = '', $tls = false, $authz = '')
--------------------Tayab-Khan--------------
No comments:
Post a Comment