# FreeBSD 13 ssmtp php



## usmcrageye (Aug 14, 2022)

Hello community,

my first post... after so much reading and time spending in this forum. First of all, I have to say, that I'm really a great fan of FreeBSD. Such a great and reliable system. I've tried some distribution, but no one was as fun, as FreeBSD. The freedom of the system is great and it's so easy to start with, in my eyes more simple than Linux, but I know it's just taste .

I've just installed and updated my RPI 3. Sadly, my backup broke and I couldn't restore my backup files. So I had to re-install freebsd to my Rasperry PI 3, this as far went very well.

Nearly no problems at all; my Website (Wordpress) works great, no problems, only one thing... I can't send E-Mail using PHP. 

I've tried so many stuff and couldn't get it working; ssmtp works fine, if I use as my logged in User and as Root, but PHP/Wordpress can't send e-mail. 

What am I doing wrong? I've even configured in php.ini the mail attributes:

```
; For Win32 only.
; https://php.net/smtp
SMTP = localhost
; https://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; https://php.net/sendmail-from
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; https://php.net/sendmail-path
#sendmail_path = /usr/local/sbin/ssmtp
#sendmail_path = /usr/local/sbin/ssmtp -t -i
#sendmail_path = /usr/local/sbin/ssmtp -t -i
sendmail_from = my-email@gmail.com
sendmail_path = /usr/local/sbin/ssmtp  -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 =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; 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 (Event Log on Windows).
;mail.log = syslog
```

ssmtp files:

```
[rpi-3:local/etc/ssmtp] Sebastian% cat revaliases
# sSMTP aliases
#
# Format:    local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:mymail@gmail.com:smtp.gmail.com:587
www:mymail@gmail.com:smtp.gmail.com:587
ssmtp:mymail@gmail.com:smtp.gmail.com:587
```


```
[rpi-3:local/etc/ssmtp] Sebastian% cat ssmtp.conf
#
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
#

# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
#root=postmaster
mymail@gmail.com

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
#mailhub=mail
mailhub=smtp.gmail.com:587

# Example for SMTP port number 2525
# mailhub=mail.your.domain:2525
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain       
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?
#rewriteDomain=
rewriteDomain=gmail.com

# The full hostname
#hostname=_HOSTNAME_
hostname=localhost

# Set this to never rewrite the "From:" line (unless not given) and to
# use that address in the "from line" of the envelope.
FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
UseTLS=YES

# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES

# Use this RSA certificate.
#TLSCert=/usr/local/etc/ssmtp/ssmtp.pem

# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment
#Debug=YES

# Use these parameters for securely authenticating against your
# mailhub; check ssmtp.conf(5) for further details.
UseSTARTTLS=YES
AuthUser=mymail@gmail.com
AuthPass=_mygoogleapppassword_
```


```
[rpi-3:/usr/local/etc] Sebastian% cat /etc/aliases
# $FreeBSD$
#    @(#)aliases    5.3 (Berkeley) 5/24/90
#
#  Aliases in this file will NOT be expanded in the header from
#  Mail, but WILL be visible over networks.
#
#    >>>>>>>>>>    The program "newaliases" must be run after
#    >> NOTE >>    this file is updated for any changes to
#    >>>>>>>>>>    show through to sendmail.
#
#
# See also RFC 2142, `MAILBOX NAMES FOR COMMON SERVICES, ROLES
# AND FUNCTIONS', May 1997
#     http://tools.ietf.org/html/rfc2142

# Pretty much everything else in this file points to "root", so
# you would do well in either reading root's mailbox or forwarding
# root's email from here.

root: mymail@gmail.com

# Basic system aliases -- these MUST be present
MAILER-DAEMON: root
postmaster: root

# General redirections for pseudo accounts
_dhcp:    root
_pflogd: root
auditdistd:    root
bin:    root
bind:    root
daemon:    root
games:    root
hast:    root
kmem:    root
mailnull: postmaster
man:    root
news:    root
nobody:    root
operator: root
pop:    root
proxy:    root
smmsp:    postmaster
sshd:    root
system:    root
toor:    root
tty:    root
usenet: news
uucp:    root

# Well-known aliases -- these should be filled in!
# manager:
# dumper:

# BUSINESS-RELATED MAILBOX NAMES
# info:
# marketing:
# sales:
# support:

# NETWORK OPERATIONS MAILBOX NAMES
abuse:    root
# noc:        root
security:    root

# SUPPORT MAILBOX NAMES FOR SPECIFIC INTERNET SERVICES
ftp:         root
ftp-bugs:     ftp
# hostmaster:     root
# webmaster:     root
www:         root   

# NOTE: /var/msgs and /var/msgs/bounds must be owned by sendmail's
#    DefaultUser (defaults to mailnull) for the msgs alias to work.
#
# msgs: "| /usr/bin/msgs -s"

# bit-bucket: /dev/null
# dev-null: bit-bucket
```

ssmtp is kinda working, as said above, I can send mails using CLI; with no problems at all (and even receive then ), what am I doing wrong? 

Sorry my for bad English, really, German is my native language .

thanks in advance for any help. 

Greetings,
Sebastian


----------



## SirDice (Aug 15, 2022)

Did you adjust mailer.conf(5) correctly? If you set that correctly 'client' applications can simply call the 'standard' mail(1) command. No need to set anything special in php.ini.


----------



## usmcrageye (Aug 15, 2022)

Hi SirDice,

thank you very much for reply. I've just checked the mailer.conf. 


```
[rpi-3:~] Sebastian% cat /etc/mail/mailer.conf
sendmail        /usr/local/sbin/ssmtp
send-mail       /usr/local/sbin/ssmtp
mailq           /usr/local/sbin/ssmtp
newaliases      /usr/local/sbin/ssmtp
hoststat        /usr/local/sbin/ssmtp
purgestat       /usr/local/sbin/ssmtp
```

I can send file using „sendmail john@example.com < /etc/rc.conf“, that's no problem, as user and as root (of course still able to receive it  ).

As permission for ssmtp I used: (as advised in handbook)

```
chown ssmtp:nogroup /usr/local/sbin/ssmtp
chmod 4555 /usr/local/sbin/ssmtp
```

Wordpress as example still tells me, its having a critical problem (for every action, which sends an E-Mail)..
maybe httpd/apache24 or php can't access  /usr/local/sbin/ssmtp ?

Greetings,
Sebastian


----------



## anlashok (Aug 16, 2022)

have you tried using port 465 for gmail,? I could never get 587 to work.

have you looked in /var/log/maillog for hints on what the problem is when sending from PHP?. You can add 
	
	



```
debug=YES
```
 to /usr/local/etc/ssmtp/ssmtp.conf to get more detail in maillog

also check permissions of /usr/local/etc/ssmtp/ and contents.


----------



## hardworkingnewbie (Aug 16, 2022)

Just as a side thought: ssmtp is a very simple mail forwarder. If the program crashes or other funny stuff happens, and getting the mail off the system didn't happen, it will just write the failed mail into the file dead.letter in your home directory and that's it. 

So if more than one mail fails and the content was important enough, this design might be something you could find problematic, because peeling it out of there again might be a little bit inconvenient. 

A suitable replacement might be Nullmailer, because this uses its own queue. Otherwise it's also just another forwarding relay program.


----------



## usmcrageye (Aug 16, 2022)

Cheers guys, thanks for your replies. 

I've set on the debug mode and checked my permissions (okay, I set them new ) but still no difference; apache/php can't send while using CLI is no problem. The port of gmail is working fine for me, whiling sending my rc.conf `sendmail mymail@vodafone.de < /etc/rc.conf`.

if do send an email using the command, I can see in the debug file, that the mail has been sent. While using Wordpress changing administrator e-mail (forces to send an e-mail to confirm the change), just let the page crash - with no change in the debug log.

I'll give Nullmailer a try, if I'm not getting smtp to work  I had ssmtp for 3 months without any problem, my website is hosted in my network without access from outside , so there's no big e-mail traffic, most mails are from root at 3:00a ;-)

thanks for you help, Sebastian


----------



## usmcrageye (Aug 16, 2022)

It really seems in my eyes, as the php/apache can't access the ssmtp mail hub, how could that be fixed? The default option from php.ini  is: 
	
	



```
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
```

if I use my cli with -t and -it the e-mail won't be send either. 

Where did I go wrong?


----------



## usmcrageye (Aug 16, 2022)

```
Aug 16 22:27:50 rpi-3 sSMTP[2362]: Set UseSTARTTLS="True"
Aug 16 22:27:50 rpi-3 sSMTP[2362]: Set AuthUser="mymail@gmail.com"
Aug 16 22:27:50 rpi-3 sSMTP[2362]: Set AuthPass="xxxxxxxxxxxxxx"
Aug 16 22:27:50 rpi-3 sSMTP[2362]: Creating SSL connection to host
Aug 16 22:27:50 rpi-3 sSMTP[2362]: 220 smtp.gmail.com ESMTP u15-20020a056402064f00b0043a7c24a669sm8966620edx.91 - gsmtp
Aug 16 22:27:50 rpi-3 sSMTP[2362]: EHLO rpi-3.fritz.box
Aug 16 22:27:50 rpi-3 sSMTP[2362]: 250 SMTPUTF8
Aug 16 22:27:50 rpi-3 sSMTP[2362]: STARTTLS
Aug 16 22:27:50 rpi-3 sSMTP[2362]: 220 2.0.0 Ready to start TLS
Aug 16 22:27:50 rpi-3 sSMTP[2362]: SSL connection using TLS_AES_256_GCM_SHA384
Aug 16 22:27:50 rpi-3 sSMTP[2362]: EHLO rpi-3.fritz.box
Aug 16 22:27:50 rpi-3 sSMTP[2362]: 250 SMTPUTF8
Aug 16 22:27:50 rpi-3 sSMTP[2362]: AUTH LOGIN
Aug 16 22:27:50 rpi-3 sSMTP[2362]: 334 VXNlcm5hbWU6
Aug 16 22:27:50 rpi-3 sSMTP[2362]: cnBpM3NlcHBpQGdtYWlsLmNvbQ==
Aug 16 22:27:50 rpi-3 sSMTP[2362]: 334 UGFzc3dvcmQ6
Aug 16 22:27:50 rpi-3 sSMTP[2362]: Z2toeWFkaG5vZGlkcHp6cg==
Aug 16 22:27:51 rpi-3 sSMTP[2362]: 235 2.7.0 Accepted
Aug 16 22:27:51 rpi-3 sSMTP[2362]: MAIL FROM:<root@gmail.com>
Aug 16 22:27:51 rpi-3 sSMTP[2362]: 250 2.1.0 OK u15-20020a056402064f00b0043a7c24a669sm8966620edx.91 - gsmtp
Aug 16 22:27:51 rpi-3 sSMTP[2362]: RCPT TO:<the-root-mailbox@vodafone.de>
Aug 16 22:27:51 rpi-3 sSMTP[2362]: 250 2.1.5 OK u15-20020a056402064f00b0043a7c24a669sm8966620edx.91 - gsmtp
Aug 16 22:27:51 rpi-3 sSMTP[2362]: DATA
Aug 16 22:27:51 rpi-3 sSMTP[2362]: 354  Go ahead u15-20020a056402064f00b0043a7c24a669sm8966620edx.91 - gsmtp
Aug 16 22:27:51 rpi-3 sSMTP[2362]: Received: by rpi-3.fritz.box (sSMTP sendmail emulation); Tue, 16 Aug 2022 22:27:50 +0200
Aug 16 22:27:51 rpi-3 sSMTP[2362]: From: "WebMail" <mymail@gmail.com>
Aug 16 22:27:51 rpi-3 sSMTP[2362]: Date: Tue, 16 Aug 2022 22:27:50 +0200
Aug 16 22:27:51 rpi-3 sSMTP[2362]: hostname="rpi-3"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: ifconfig_DEFAULT="DHCP"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: sshd_enable="YES"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: sendmail_enable="NO"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: sendmail_submit_enable="NO"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: sendmail_outbound_enable="NO"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: sendmail_msp_queue_enable="NO"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: growfs_enable="YES"
Aug 16 22:27:51 rpi-3 sSMTP[2362]:
Aug 16 22:27:51 rpi-3 sSMTP[2362]: sstmp_flags="-4"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: ntpd_enable="YES"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: ntpd_sync_on_start="YES"
Aug 16 22:27:51 rpi-3 sSMTP[2362]:
Aug 16 22:27:51 rpi-3 syslogd: last message repeated 1 times
Aug 16 22:27:51 rpi-3 sSMTP[2362]: apache24_enable="yes"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: mysql_enable="yes"
Aug 16 22:27:51 rpi-3 sSMTP[2362]: sendmail_cert_create="NO"
Aug 16 22:27:52 rpi-3 sSMTP[2362]: .
Aug 16 22:27:53 rpi-3 sSMTP[2362]: 250 2.0.0 OK  1660681673 u15-20020a056402064f00b0043a7c24a669sm8966620edx.91 - gsmtp
Aug 16 22:27:53 rpi-3 sSMTP[2362]: QUIT
Aug 16 22:27:53 rpi-3 sSMTP[2362]: 221 2.0.0 closing connection u15-20020a056402064f00b0043a7c24a669sm8966620edx.91 - gsmtp
Aug 16 22:27:53 rpi-3 sSMTP[2362]: Sent mail for root@gmail.com (221 2.0.0 closing connection u15-20020a056402064f00b0043a7c24a669sm8966620edx.91 - gsmtp) uid=0 username=root outbytes=676
```

this come if I use the command from above; but if I try sending an e-mail with php, nothing happens in this log.


----------



## anlashok (Aug 16, 2022)

it does sound as if the www user doesn't have permission to access either the ssmtp binary or the config directory

my php.ini settings, note you have a couple of Win32 only lines uncommented in yours although those are probably ignored

```
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from =

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/local/sbin/ssmtp -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 = Off

; 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 =
```

permissions on /usr/local/sbin/sstmp are

```
-r-xr-sr-x  1 root  ssmtp  44032 Oct 25  2020 ssmtp
```
and permissions on /usr/local/etc/ssmtp/ are

```
-rw-r--r--   1 root  ssmtp   778 Aug 15  2018 revaliases
-rw-r--r--   1 root  ssmtp  1008 Jan 12  2022 ssmtp.conf
```


----------



## usmcrageye (Aug 17, 2022)

I couldn't change the permissions yet, I'm missing the chmod numbers, sorry, I'm new in the freebsd world.

What I've tried and worked well, was sending an e-mail as www, by using: `sudo -u www /usr/local/sbin/ssmtp memyotheremailaddres@live.nl < /etc/rc.conf`

this works, but php still can't send e-mails, I'm thinking to give up, this is a very strange behavior, if the command as www can access the /usr/local/sbin/ssmtp, why can't php open it? 

I've changed the path into the php ini (but -t isn't working, as said above):

```
[mail function]
; For Win32 only.
; https://php.net/smtp
SMTP = localhost
; https://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; https://php.net/sendmail-from
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; https://php.net/sendmail-path
;sendmail_path = sendmail -i
sendmail_path = /usr/local/sbin/ssmtp -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 =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; 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 (Event Log on Windows).
;mail.log = syslog
```

If I'm using -t in CLI:

```
[rpi-3:~] Sebastian% sudo -u www /usr/local/sbin/ssmtp -t -i oneofmy1000mailboxes@live.nl < /etc/rc.conf
ssmtp: recipients with -t option not supported
```

Could you please tell me the chmod numbers, chown would be root:ssmtp for socket and files, as I read of your code above. 

is there maybe an PHP missing for using the ssmtp socket?
thanks again for your help.

btw sooner or later I'll kill this bloody auto correction in Safari, always makes me write smtp instead of ssmtp...


----------



## kalleboy (Aug 17, 2022)

Would this one help?






						FreeBSD&PHP: How to activate php mail() and send emails from PHP/WordPress (Any CMSs) – Özgür Kazanççı | Blog
					

FreeBSD&PHP: How to activate php mail() and send emails from PHP/WordPress (Any CMSs)




					ozgurkazancci.com
				




few weeks ago i had exactly the same problem.. after moving few wordpress websites of mine from one VPS to another, solved it with that link. (applied from the beginning, step by step, and I didn't touch anything inside php.ini at all)


----------



## usmcrageye (Aug 17, 2022)

Hi Kalleboy,

that's exactly the website, I've used as instruction, to install my rpi-3. Was it maybe wrong to first install php, apache (+mysql) and then to config ssmtp? Wrong order?

dammit, I can't believe that I don't get it too work. Did you change/edit something on /etc/aliases? Did you follow the steps the exact same way as described? 

I'll re-install freebsd on a second sd card this evening and give a it a second try (without touching my existing install).

again, thanks guys, for all of your help!


----------



## anlashok (Aug 17, 2022)

```
# ls -l ssmtp
-rwxrwxrwx  1 root  ssmtp  0 Aug 17 17:53 ssmtp
# chmod 2555 ssmtp
# ls -l
-r-xr-sr-x  1 root  ssmtp  0 Aug 17 17:53 ssmtp
```
chmod 2555 is equivalent to chmod ugo=rx,g+s file, which means for user,group,other set permission to read+execute and add setgid to group which means that php would execute ssmtp with the effective permissions of the ssmtp group. Just sharing what is currently working for me.

looking at the guide you followed your ssmtp executable should have the following permissions following the command shown, which is doing roughly the same as my permissions except its letting php execute ssmtp with effective permissions of the psuedo ssmtp user you created a few steps earlier


```
# chmod 4555 ssmtp
# ls -l
-r-sr-xr-x  1 ssmtp  nogroup  0 Aug 17 17:53 ssmtp
```

comment out the SMTP and smtp_port lines in php.ini as well as they are Win32 only directives

```
[mail function]
; For Win32 only.
; https://php.net/smtp
;SMTP = localhost
; https://php.net/smtp-port
;smtp_port = 25
```


----------



## anlashok (Aug 17, 2022)

if you want a simple command line php file to test emailing, this will suffice.

```
ee mail.php
<?php

$subject="subject text";
$body="body text";
$to="youremail@yourdomain.com";

mail($to,$subject,$body);
?>
```
then you can execute like this

```
# php mail.php
```
which will send the email just using your php settings. this will rule out if the issue is in Wordpress itself


----------



## usmcrageye (Aug 17, 2022)

It was also a though of me, that it's that damn WP installation, which is just messed up. I'll test the script of you and I'll give the new PHP ini a try, I'll reinstall FreeBSD from begin off, but is there any guide which describes the installation without creating the ssmtp user,  as described in the guide of Kalleboy?

Thanks again for your help anlashok


----------



## anlashok (Aug 17, 2022)

adding the user is just a way to enhance the security of the details in the ssmtp.conf and revaliases files. if you are using this on a system completely in your control and you are happy that it won't be abused, then you can just uninstall and reinstall ssmtp to set it back to the default permissions and enter your configuration settings in those two files, update the mailer.conf and php.ini to point at the binary and run it like that. it should just work out of the box.

as an alternative you could investigate dma which is in base and will also work as a send only mail agent. see here for basic setup for either dma or ssmtp as outgoing mail.


----------



## usmcrageye (Aug 17, 2022)

hi anlashok,

as you said, I did, thanks again for your reply! This forum is really great, haven't had such great experience as this with other forums btw.. Even if it doesn't quite work yet, I'm still lucky that I've choose for freebsd.

this is ssmtp folder /usr/local/etc/ssmtp:

```
[rpi-3:local/etc/ssmtp] Sebastian# ls -la
total 24
drwxr-x---   2 root  ssmtp   512B 17 aug. 22:40 .
drwxr-xr-x  17 root  wheel   1,0K 17 aug. 14:08 ..
-rw-r--r--   1 root  ssmtp   377B 16 aug. 22:30 revaliases
-rw-r-----   1 root  ssmtp   200B 14 apr. 21:35 revaliases.sample
-rw-r--r--   1 root  ssmtp   377B 17 aug. 22:40 ssmtp.conf
-rw-r-----   1 root  ssmtp   1,4K 14 apr. 21:35 ssmtp.conf.sample
```

seems nearly exactly as yours above, now the „socket“:
/usr/local/sbin/

```
[rpi-3:/usr/local/sbin] Sebastian% ls -la ssmtp
-r-xr-sr-x  1 root  ssmtp    32K 14 apr. 21:35 ssmtp
```
seems also to be like yours (-r-xr-sr-x)

but.... yes, success, my user „Sebastian“, no root, well member of wheel, can send mails:
`[rpi-3:/usr/local/etc] Sebastian% sendmail ivegottomanymails@vodafone.de < /etc/rc.conf`

this works fine, the e-mail sent can be received. Luckily, one thing that works, yay 

second but: php mail doesn't work - still:
`[rpi-3:/usr/local/etc] Sebastian% php /usr/local/www/apache24/data/mail2.php

ssmtp: No recipients supplied - mail will not be sent`

```
[rpi-3:/usr/local/etc] Sebastian% cat /usr/local/www/apache24/data/mail2.php
<?php

$subject="subject text";
$body="body text";
$to="myname@vodafone.de";

mail($to,$subject,$body);
?>
```

my php.ini mail section:

```
[mail function]
; For Win32 only.
; https://php.net/smtp
;SMTP = localhost
; https://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; https://php.net/sendmail-from
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; https://php.net/sendmail-path
sendmail_path = /usr/local/sbin/ssmtp

; 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 =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; 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 (Event Log on Windows).
;mail.log = syslog
```
btw still mail path with -t doesn't work? 

so my normal user can now send mails, but my php still can't... so I think my apache either. Thanks again for your time and your help!

greetings,
Sebastian


----------



## usmcrageye (Aug 17, 2022)

me, once again...

I've got it working; even with www. But my Wordpress is still messing it up; critic error, while sending mails... but hey, this is something, I can figure out... I've used wp-smtp and changed the e-mail from the blog to the one, which my ssmtp uses... worked earlier, why it's not working yet, I don't know....

but...
I've added to the php.ini to the mail path:
sendmail_path = /usr/local/sbin/ssmtp -t -I -f

this worked for the provided php script from you. This worked well:





but Wordpress... that's another story, I'll care about it tomorrow... Thanks again for your help, thank you so much!


----------



## usmcrageye (Aug 20, 2022)

Hey guys,

thanks again for all of you and all of your help. Thanks! Great community, I'm happy it's back working.

For People looking for good instruction, I'd recommend the URL from Kalleboy.


kalleboy said:


> Would this one help?
> 
> 
> 
> ...



This worked fine, to rights and permissions I've used the tips and tricks from anlashok:








						FreeBSD 13 ssmtp php
					

Hello community,  my first post... after so much reading and time spending in this forum. First of all, I have to say, that I'm really a great fan of FreeBSD. Such a great and reliable system. I've tried some distribution, but no one was as fun, as FreeBSD. The freedom of the system is great and...




					forums.FreeBSD.org
				




this all both worked great for me, even sendmail -t does work now - I think this has something to do, with the /etc/mai/mailer.conf, see in the url from kalleboy.

now sending mails with php shows the receiver of the e-mail (script used above from anlashok:https://forums.FreeBSD.org/threads/freebsd-13-ssmtp-php.86167/post-578691) (the receiver is saved as contact in my address book):





one more line, I've added to the ssmtp/reval... was the user www:

```
[rpi-3:~] Sebastian% cat /usr/local/etc/ssmtp/revaliases
# sSMTP aliases
#
# Format:    local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:xxxgmail.com:smtp.gmail.com:587
ssmtp:xxx@gmail.com:smtp.gmail.com:587
www:xxx@gmail.com:smtp.gmail.com:587
```


otherwise I've downgraded php - from 8.1 to 7.4, made also Wordpress response faster. And changed the PHP.ini back to default one (no customized sendmail path) - for the Rasperry the only thing I'd recommend to change, is the memory size/limit. Further more, I've used the  WP-SMTP Plugin in Wordpress, to change the sender mail address of my website, to the e-mai I've used in the ssmtp config.

That's it, thanks again guys, for all of you and your help.
Thank you sooooooo much, finally I'm back - with my website .

greetings, 
Sebastian


----------



## richardtoohey2 (Aug 20, 2022)

usmcrageye said:


> I've downgraded php - from 8.1 to 7.4


7.4 is EOL in 3 months: https://www.php.net/supported-versions.php


----------



## usmcrageye (Aug 20, 2022)

Cheers richardtoohey2,

yes, I know, but by RPI is intern (192.168.251x/23), in my network behind a cable router with firewall, so no access from outside (incoming, no DMZ, no open ports), in my eyes not that bad. 

But yes, you're right.


----------



## kalleboy (Aug 23, 2022)

usmcrageye said:


> Hey guys,
> 
> thanks again for all of you and all of your help. Thanks! Great community, I'm happy it's back working.
> 
> ...



Please note that Wordpress runs much faster with 8.0.x, rather than 7.x ones.


----------



## usmcrageye (Aug 24, 2022)

kalleboy said:


> Please note that Wordpress runs much faster with 8.0.x, rather than 7.x ones.


I'll give it a try, but as long it's working it's fine for me... Its just already much faster, since I've changed also the SD Card, dunno why... I'll give it a try, but as said, on an other SD Card, I'm not risking my productive installation, what I'm using right now. I'll report about my second installation with php 8.x  thanks again mate.


----------

