How to send mail (sendmail) for php mail()?

PHP mail() function doesn't work.

Nor does sendmail:

loaded system configuration file /etc/msmtprc
ignoring user configuration file /home/xi/.msmtprc: No such file or directory
falling back to default account
using account default from /etc/msmtprc
host = xsi
port = 25
proxy host = (not set)
proxy port = 0
timeout = off
protocol = smtp
domain = localhost
auth = none
user = (not set)
password = (not set)
passwordeval = (not set)
ntlmdomain = (not set)
tls = off
tls_starttls = on
tls_trust_file = (not set)
tls_crl_file = (not set)
tls_fingerprint = (not set)
tls_key_file = (not set)
tls_cert_file = (not set)
tls_certcheck = on
tls_min_dh_prime_bits = (not set)
tls_priorities = (not set)
auto_from = off
maildomain = (not set)
from = nobody@xidev.tk
add_missing_from_header = on
add_missing_date_header = on
remove_bcc_headers = on
dsn_notify = (not set)
dsn_return = (not set)
logfile = (not set)
syslog = LOG_MAIL
aliases = (not set)
reading recipients from the command line and the mail

cat /etc/ssmtp/ssmtp.conf

# Example for a system wide configuration file
# A system wide configuration file is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default
# The SMTP smarthost.
host xsi
# Construct envelope-from addresses of the form "user@oursite.example".
#auto_from on
#maildomain oursite.example
# Use TLS.
#tls on
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER.
syslog LOG_MAIL

xi@xsi ~ $ cat /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d.  To create a more complete configuration,
# please review /usr/share/doc/openrc*/net.example* and save your configuration
# in /etc/conf.d/net (this file :]!).
hostname=xi
config_eth0="192.168.137.2/24 brd 192.168.137.255"
routes_eth0="default via 192.168.137.1"
# The network scripts are now part of net-misc/netifrc
# In order to avoid sys-apps/openrc-0.12 from removing this file, this comment was
# added; you can safely remove this comment.  Please see
# /usr/share/doc/netifrc*/README* for more information.

xi@xsi ~ $ cat /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d.  To create a more complete configuration,
# please review /usr/share/doc/openrc*/net.example* and save your configuration
# in /etc/conf.d/net (this file :]!).
hostname=xi
config_eth0="192.168.137.2/24 brd 192.168.137.255"
routes_eth0="default via 192.168.137.1"

How to send via sendmail without any other outer mail? I just want to send by testing sendmail on command line. Which minimum amount of setup work do I have to do (generally)?

sendmail -f "nobody@xidev.tk" -vt <mail.txt
xi@xsi ~ $ cat mail.txt

(I don't really need any email-server
I need activation email with php, thanks)

Who's got working mail() via sendmail? How did you set it up to work?

I was advised to use msmtp. As far as I could see some people defend the position of setting up the outer mail. I don't know it - how it's called "relay ".. I don't need it IF IT'S POSSIBLE. Another wide-spread opinion in google search results is to ask a provider to write a PTR record into outer DNS zone.
I HOPE NOT and hope I will silently send my activation hash to user's email after registration from my peaceful home without disturbing any providers support or other services.

(Gentoo Linux)
I'm waiting for your help, I wish the way of learning sendmail and php mail() will be just full of just-needed information ...PHPmailers.. libraries - rather not.
However, you might prove to me that's simply just to learn email protocol and write my own php..
(like it was on #gentoo channel:

I'm such a green newbie even in js ..guys.. PHP xD .. and apart I see the immense fields of standards huge & cumbersome

....

  1. What to write in each config php.ini httpd.conf ssmtp.conf
  2. What parameters to write to sendmail to just test
  3. What I must put into other system-wide config files?

sendmail on your system is just ssmtp.

ssmtp won't work until you configure it. See all those 'not sets'? They're not set.

You need to set at least 'mailhub', 'AuthUser', and 'AuthPass' in ssmtpd.conf for it to try to connect to a mail server. What those are, depends on what email and mail server you want it to connect to.

1 Like