When you set up Apache in vpn you also might want to send emails with PHP. You can use msmtp to send emails from the system using smtp. Eliminating the need to use some php library for smtp.
Get msmtp, which is a very simple and easy to use SMTP client with fairly complete sendmail compatibility. Use your favourite package manager to get msmtp package.
Source code viewer
yay -S msmtpProgramming Language: Bash
Create a new configuration file for the smtp settings. There is no default config file in etc for msmtp.
Source code viewer
# Default global settings. defaults # Use authentication SSL/TLS. auth on tls on tls_starttls off # Log errors to systemlog. Easiest way to log with log-rotation out of the box. syslog on # Set timeout for the email sending. timeout 5 # Setup your smtp "profile". account [profile-name] host [host-address] port [port] from [default-from-email-address] user [smtp-username] password [smtp-password] # Set your smtp "profile" as default. account default : [profile-name]Programming Language: INI
Set sendmail_path in /etc/php/php.ini so mail() funtion in PHP will work.
Source code viewer
sendmail_path = /usr/bin/msmtp -C /path/to/msmtp.conf -tProgramming Language: INI
# This file has to be owned by apache user and permissions set to 600 or you get a security error from msmtp.
Source code viewer
sudo chown www-data:users /dir/to/msmtp.conf sudo chmod 600 /dir/to/msmtp.confProgramming Language: Bash
Test your work and see if everything works.
Source code viewer
echo -e "Subject: Test email" | /usr/bin/msmtp -v -C /dir/to/msmtp.conf sent-to@example.comProgramming Language: Bash