I mentioned a strange behavior on my webpage: If I try to use Joomla to send Mails via SMTP it works fine; no problem at all.

But: If I try to use a PHP-CLI-Script the action fails (same source code).

            $mailer = JFactory::getMailer();
            $config = JFactory::getConfig();
            $sender = array( 
            $mailer->Encoding = 'base64';
            $send = $mailer->Send();

If I do not use SMTP to send the mail but sendmail or php-mail, it works fine from PHP and PHP-CLI.

So my thought was, that there is possibly something in my php.ini for php-cli which blocks my cli-script from sending via SMTP.

Do you have an idea what to do?

  • My first idea is to look in the mailserver logs. Also my second, and my third. – Jenny D Jun 15 '15 at 9:15
  • Hm, these are the entries :-/ Not much I can read from them :-( Jun 15 11:51:49 myserver nullmailer[2376]: Starting delivery: protocol: smtp host: mail.example.com file: 1434326633.1008 Jun 15 11:51:49 myserver nullmailer[2376]: Starting delivery, 4 message(s) in queue. – MyFault Jun 15 '15 at 9:54
  • Ah, of course, there was an error: The server sends via another server (SMTP-Server, which is given in my Joomla-Installation, which runs the CLI-App). Now it shows up, that the username is unknown in the virtual mailbox table. But of course it is, because the mail is delivered to the wrong server (test.example.com[193.xxx.xxx.xx] instead of mail.example.com). But the MX-Record for example.com is mail.example.com and not test.example.com. – MyFault Jun 15 '15 at 10:00
  • Do you have a CNAME-Record for example.com? Does A-Record for example.com poitns to the "another SMTP server? – AnFi Jun 17 '15 at 14:46

You can specify the path to php.ini passing option

--php-ini FILENAME

to the php executable.

Try again giving the path to the php.ini used by the webserver.

  • HI there, I tried that already - without success :-( If I run php -c /var/www/web1/conf/php.ini -r "phpinfo();" it shows me that the php.ini which is used by the web server is used. – MyFault Jun 15 '15 at 9:50
  • that rules out differences in the php.ini config. Do you get some error message? – Silvio Massina Jun 15 '15 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.