4

I'm using ubuntu 16.04 and PHP 7. I make a website that allows admin to send an email to other admin. So I installed SSMTP and configured it properly. Here is the thing :

  1. I can send an email by using terminal with this code :

    sudo ssmtp myother@gmail.com
    
  2. I can send an email by using PHP but from terminal. So I use this

    php index.php
    

but I can't send an email from browser (by going to localhost/sendemail). What's the problem ?

note : I've changed this in php.ini :

sendmail_path = /usr/sbin/ssmtp -t
  • In the first example there is sudo command, do you need root privileges also for the second one? If that is the case maybe you need to grand sudo privileges to www-data for this command. Use sudo visudo and add this line: www-data ALL=(ALL) NOPASSWD: /usr/sbin/ssmtp. – pa4080 Jun 11 '17 at 20:15
  • Yes, in the second one I should use sudo too. And it's still not working tough.. – Zainab Safiyyah Al-habsyi Jun 12 '17 at 3:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.