Open-source Languages & Tools for z/OS

 View Only
  • 1.  PHP and send mail out

    Posted 05-14-2018 18:04

    You ever bang you head against several issues that a simple solution seems too fuzzy to figure out? Well, that’s where I think I am. I’m dealing with a couple of issues like php mail, sendmail, and the sendmail to cssmtp bridge. Thought I take baby steps to figure out what I may be doing wrong.
    I’m running zos2.2 and just trying to use sendmail for now. This is the first time I’ve ever played with php. I’ve gotten a helloworld.php program to work. So I grabbed a simple php to mail comments to myself. (of course there is more to it than this line).
    mail( $webmaster_email,“Feedback Form Results”,$msg )
    but I get this error.
    NOQUEUE: SYSERR(userid): EZZ9892I unable to setreuid from 1 to 0: EDC5121I Invalid argument
    This is where the fuzzy comes in. I’ve tried so many things to fix the first part, I’m not sure what might work. I believe it’s my configuration but not sure where. The second part I’m not sure about. Any help would be much appreciated.

  • 2.  RE: PHP and send mail out

    Posted 05-15-2018 06:13

    Hi Jeff,

    Could you please provide us the output of the commands:

    1. PHP version
      php --version
      and also it would be better to see a number of the build from README.ZOS
    2. Is there a path to sendmail?
      which sendmail
    3. Is sendmail working for you?
      echo "Subject: sendmail test" | sendmail -v
    4. Verify that path to sendmail available for php:
      php -i | grep sendmail
    5. If sendmail is not working, probably, suid bit is not set on sendmail binary:
      ls -la /bin/sendmail
      In my case, I have a link:
      lrwxrwxrwx 1 ROOT … /bin/sendmail -> …/usr/lpp/tcpip/bin/sendmail
      so there is need to do this command again:
      ls -la /usr/lpp/tcpip/bin/sendmail
      -rwsr-sr-x 2 SMMSP SMMSPGRP 2252800 Aug 16 2016 /usr/lpp/tcpip/bin/sendmail

    These ‘s’ are suid and guid bits that must be set to have user’s and group’s execute permissions.

  • 3.  RE: PHP and send mail out

    Posted 05-16-2018 08:55

    1 PHP 5.4.4 (cli) (built: Nov 21 2016 03:25:49)
    Copyright © 1997-2012 The PHP Group
    Zend Engine v2.4.0, Copyright © 1998-2012 Zend Technologies

    Build from the VERSION.ZOS file

    Tool: php
    Version: 5.4.4
    Build Number: 0006

    find / -name ‘sendmail’

    /usr/sbin/sendmail symbolic link to /usr/lpp/tcpip/sbin/sendmail
    /bin/sendmail symbolic link to /usr/lpp/tcpip/bin/sendmail

    1. I received the email. (Interesting about the configuration file)

    echo “Subject: sendmail test” | sendmail -v

    Msmtp: Warning: first argument in [IPC] mailer must be TCP or FILE
    Mesmtp: Warning: first argument in [IPC] mailer must be TCP or FILE
    Msmtp8: Warning: first argument in [IPC] mailer must be TCP or FILE
    Mrelay: Warning: first argument in [IPC] mailer must be TCP or FILE
    Warning: .cf file is out of date: sendmail 8.12.1p4 supports version 10, .cf file is version 7… Connecting to smtp.server via esmtp…
    220 mail2.server ESMTP Smtpd; Tue, 15 May 2018 07:37:02 -0700

    EHLO test.mainframe
    250-mail2.server Hello test.mainframe [], pleased to meet you
    250-SIZE 71828480
    250 HELP

    MAIL From:me@test.mainframe
    250 2.1.0 me@test.mainframe… Sender ok

    250 2.1.5… Recipient ok
    354 Enter mail, end with “.” on a line by itself

    250 2.0.0 w4FEb29Q022974-w4FEb29R022974 Message accepted for delivery… Sent (w4FEb29Q022974-w4FEb29R022974 Message accepted for delivery)
    Closing connection to smtp.server.

    221 2.0.0 mail2.server closing connection

    php -i | grep sendmail

    sendmail_from => no value => no value
    sendmail_path => /bin/sendmail -t -i => /bin/sendmail -t -i
    Path to sendmail => /bin/sendmail -t -i

    ls -la /bin/sendmail

    lrwxrwxrwx 1 Root OMVSGRP 29 Mar 23 2016 /bin/sendmail -> …/usr/lpp/tcpip/bin/sendmail

    ls -la /usr/lpp/tcpip/bin/sendmail

    -rwsr-sr-x 2 Root OMVSGRP 2252800 Jan 10 2017 /usr/lpp/tcpip/bin/sendmail

  • 4.  RE: PHP and send mail out

    Posted 05-16-2018 10:32

    After seeing the warning of the .cf file for sendmail, I took a closer look at it. In there I fixed my issue, all be it not a perfect fix but at least my php is working.

  • 5.  RE: PHP and send mail out

    Posted 05-15-2018 08:28

    Hi Jeff,

    Actually, php mail() does nothing but call ‘/usr/sbin/sendmail -t -i’ with message headers “To:” and “Subject:” set to the first and the second parameters of mail() respectively. ‘/usr/sbin/sendmail -t -i’ is the default. It can be changed with ‘sendmail_path’ parameter in php.ini configuration file.