php sendmail

if i wanted to use gmail
ssl://smtp.gmail.com:465


how would I change
/usr/sbin/sendmail



#!/bin/sh
logger -p mail.crit lx-sending mail for `id -un 2>/dev/null` > /dev/null 2>&1
export DKSIGN=/var/qmail/control/domainkeys/%/private
export RELAYCLIENT=
exec /var/qmail/bin/sendmail "$@"

Open in new window

LVL 1
rgb192Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nbandanCommented:
To use an external mail server from with in PHP you will need to modify your php.ini file, specifically the [mail function] section. In that section you can specify the SMTP server you would like to use.
rgb192Author Commented:
so would i have to change the attached file
IanThCommented:
these days most linux servers have pear installed by default
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

rgb192Author Commented:
how could i see if pear is installed

and if it is,
where do i put my smtp info
IanThCommented:
write this to a php file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
/* $path = "/usr/local/bin/pear";
set_include_path(get_include_path() . PATH_SEPARATOR . $path); */
require_once 'System.php';  
var_dump(class_exists('System'));
require_once 'PEAR.php';
var_dump(class_exists('PEAR'));
require_once '/home/fhlinux195/o/oswaldinns.co.uk/user/htdocs/install/PEAR/Mail/mime.php';
var_dump(class_exists('mime'));
/* require_once 'Mail.php';
var_dump(class_exists('Mail')); */
phpinfo ();
?>
</body>
</html>
nbandanCommented:
You can check if pear is installed by running this command: pear version

If pear is installed then you can use the attached code to test a SMTP service. If pear is not installed you will need to modify you php.ini file as stated previously.
<?php
  require_once "Mail.php";

  $from = "Firstname Lastname <email@example.com>";
  $to = "Firstname Lastname <recipient@example.com>";
  $subject = "Testing with Pear!";
  $body = "Hi,\n\nThis is a test email";
  
  $host = "ssl://smtp.gmail.com";
  $port = "465";
  $username = "smtp_username";
  $password = "smtp_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>");
  }
?>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rok-KraljCommented:
                       $pm=new phpmailer;
                        
                        $pm->IsSMTP(); // telling the class to use SMTP
                        $pm->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                        $pm->SMTPAuth   = true;                  // enable SMTP authentication
                        $pm->Host       = "ssl://smtp.gmail.com:465"; // sets the SMTP server
                        $pm->Username   = "x@gmail.com"; // SMTP account username
                        $pm->Password   = "dasdsad";        // SMTP account password
                        
                        $pm->CharSet = 'UTF-8';
                        
                        $pm->Subject='asdasd';
                        $pm->AddAddress('get@ms.com');
                        
                        $pm->SetFrom('x@gmail.com'); //must be same as account
                        //$pm->SetFrom($result['od'] . '@' . $result['domena'], $result['ime']);
                        
                        $pm->isHTML(true);
                        $pm->Body = $result['vsebina'];
                        
                        
                        if (!$pm->Send()) {
                              echo 'FAILED!';
                        }
rgb192Author Commented:
pear version
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/gd.so' - libt1.so.5: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/gd.so' - libt1.so.5: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  Module 'mcrypt' already loaded in Unknown on line 0

Warning: Module 'mcrypt' already loaded in Unknown on line 0
PEAR Version: 1.6.2
PHP Version: 5.2.1
Zend Engine Version: 2.2.0
Running on: Linux
nbandanCommented:
Ok you obviously have some PHP errors to deal with. I would check that the .so files actually exist there. Aside from the errors, the test mail code I provided above should work. Did you try it? Did it work?
rgb192Author Commented:
thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.