Hello @nilmerg,
I hope you are well. I have added the SMTP setting in my php.ini file but the email is still not working. I have two php.ini files on my system and I have added the SMTP setting to both but the SMTP server name is not showing in the logs. Any help would be excellent. Sorry for my inexperience on php.
Please see the files below.
php -v
PHP 5.6.33 (cli) (built: Feb 19 2018 14:53:27)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
/etc/php.ini
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtphostname.company.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/sbin/sendmail -t -i
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On
; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =
/opt/rh/rh-php71/root/usr/bin/php -v
PHP 7.1.30 (cli) (built: Oct 29 2019 15:34:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
/etc/opt/rh/rh-php71/php.ini
[mail function]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/sbin/sendmail -t -i
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail().
;mail.force_extra_parameters =
SMTP = smtphostname.company.com
; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On
; The path to a log file that will log all mail() calls. Log entries include
; the full path of the script, line number, To address and headers.
;mail.log =
; Log mail to syslog;
;mail.log = syslog
/var/log/mail.log
Jan 25 16:04:39 USDCXVDAS117 sendmail[10448]: 10PL4da3010448: Authentication-Warning: USDCXVDAS117.company.com: apache set sender to myname@company.com using -f
Jan 25 16:04:39 USDCXVDAS117 sendmail[10448]: 10PL4da3010448: from=myname@company.com, size=914, class=0, nrcpts=1, msgid=<202101252104.10PL4da3010448@USDCXVDAS117.company.com>, relay=apache@localhost
Jan 25 16:04:39 USDCXVDAS117 sendmail[10449]: 10PL4dDg010449: from=<myname@company.com>, size=1257, class=0, nrcpts=1, msgid=<202101252104.10PL4da3010448@USDCXVDAS117.company.com>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Jan 25 16:04:39 USDCXVDAS117 sendmail[10448]: 10PL4da3010448: to=myname@company.com, ctladdr=myname@company.com (48/48), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30914, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (10PL4dDg010449 Message accepted for delivery)
Jan 25 16:04:39 USDCXVDAS117 sendmail[10451]: 10PL4dDg010449: to=<myname@company.com>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=121257, relay=company.com. [10.157.91.177], dsn=4.0.0, stat=Deferred: Connection refused by company.com.
Regards
Alex