# php, apache, ssmtp not working



## Johnny2Bad (Jan 22, 2017)

Hello folks,
I am trying desperately to get ssmtp to work but without much luck.

I followed a number of tutorials on the net. But still ssmtp refuses to forward emails with the php mail function. It does however do the daily and weekly FreeBSD reports.

Here's my system details....
`uname -a`

```
FreeBSD paranoia 10.3-RELEASE-p11 FreeBSD 10.3-RELEASE-p11 #0: Mon Oct 24 18:49:24 UTC 2016     [email]root@amd64-builder.daemonology.net[/email]:/usr/obj/usr/src/sys/GENERIC  amd64
```

My ssmtp.conf file (edited)

```
MailHub=mailhub.com:25
UseTLS=NO
Root=somebody@emailserver.com
UseSTARTTLS=NO
```

My ISP's SMTP server does not require authentication.

My php.ini sendmail entry.....

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

I suspect the above is the root of the problem but I could be wrong.

I have disabled sendmail at startup.

Any help would be much appreciated.

Peace,
Jonathan.


----------



## chrbr (Jan 22, 2017)

Johnny2Bad said:


> sendmail_path = /usr/sbin/ssmtp -t


The only thing I can imagine is that the link to /usr/sbin/ssmtp does not exist. I have not tested it, but the real "binary" should be present as /usr/local/bin/ssmtp. `whereis ssmtp` should give the information.


----------



## obsigna (Jan 22, 2017)

Johnny2Bad said:


> ...
> My ISP's SMTP server does not require authentication.
> ...


For sure your ISP has some sort of authentication mechanism in place. It maybe IP based, or it may be the quite common POP before SMTP authentication scheme. In the latter case, you won't be able to pass emails by the way of your ISP using ssmtp. Usually ISP's offer different authentication choices in order to accommodate for all the different mail clients.

I would start troubleshooting by testing if you really could send out e-mails without authentication using telnet. There are several tutorials on how to do this in the internet, a quick Google search gave a lot of examples, and the following seems to be useful:

https://mediatemple.net/community/products/dv/204404584/sending-or-viewing-emails-using-telnet

Once you completed the manual test successfully, you would continue troubleshooting the ssmtp settings.


----------



## Johnny2Bad (Jan 23, 2017)

Well I had a look at `whereis ssmtp`, you were quite correct chrbr I had the wrong path for ssmtp. It should have been /usr/local/sbin/ssmtp *not* /usr/sbin/ssmtp. It did perform in the sense of the mail function returning true. But still failed to send the email.

I do not believe the authentication is an issue obsigna as the daily and weekly reports come through.

The instructions I followed were at https://pydio.com/en/docs/kb/plugins/setting-emailers and the two notable lines in the instructions are....

```
mv /usr/sbin/sendmail /usr/sbin/sendmail.org

ln -s /usr/local/sbin/ssmtp /usr/sbin/sendmail
```

If this is correct, shouldn't the sendmail entry in php.ini be.....

```
sendmail_path = /usr/sbin/sendmail -t
```

This does not work either. Still at a loss. Will try the telnet thing in a couple of hours 

Thank you so far for your help.

Peace,
Jonathan.


----------



## SirDice (Jan 23, 2017)

Johnny2Bad said:


> The instructions I followed were at https://pydio.com/en/docs/kb/plugins/setting-emailers and the two notable lines in the instructions are....
> 
> ```
> mv /usr/sbin/sendmail /usr/sbin/sendmail.org
> ...


Bad instructions.

Handbook: 27.4. Changing the Mail Transfer Agent


----------



## Johnny2Bad (Jan 24, 2017)

Okay, so the instructions are bad. Which would have to be true as it doesn't work. But could someone please tell me explicitly what the php.ini send mail option should be?

If nessecary I'll remove ssmtp and re-install it. There's so much conflicting information out there.


----------



## anlashok (Feb 1, 2017)

mine is set as follows in php.ini

```
sendmail_path = /usr/local/sbin/ssmtp -t -i
```

also make sure you have setup an ssmtp revaliases entry for the uid you are running apache/php server as , eg www . For me it didn't work until the revaliases entry was present

```
/usr/local/etc/ssmtp/revaliases
www:your_login@your.domain:mailhub.your.domain[:port]
```


----------



## Johnny2Bad (Feb 2, 2017)

Thank you so much the above two steps resolved the problem.

Peace,
Jonathan.


----------

