Web Interface can't send mails (Linux)

Started by Stefan1200, March 19, 2016, 01:12:23 PM

Previous topic - Next topic

Stefan1200

The JTS3ServerMod Web Interface is using the PHP mail function to send mails, if someone registered to the Web Interface or used the resend password function. PHP itself requires an SMTP client to send a mail. In most cases a fully configured web server should have this.

If you don't have a mail server installed, you could install a full-featured mail transfer agent (MTA) like Postfix to serve this function. But it's overkill if you only need to send mail through PHP, instead just install msmtp. It's lightweight and much simpler to configure.


Install msmtp
Install the packages msmtp and ca-certificates
Example on Debian:
apt-get install msmtp ca-certificates


Configure msmtp
Create a new configuration file at /etc/msmtprc with the following configuration information:
# Set default values for all following accounts.
defaults

# Enable or disable TLS/SSL encryption.
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

# Set up a default account's settings.
account default
host <smtp.example.net>
port 587
auth on
user <username@example.net>
password <password>
from <address-to-receive-bounces@example.net>
logfile /var/log/msmtp/msmtp.log


You need to put your own configuration information at host/username/password/from, make sure that you removed the brackets as well. For host/username/password, use your normal credentials for sending mail through your mail provider.

Tell PHP to use it, open your php.ini file, might be at /etc/php5/apache2/php.ini
To know the real path, check out the phpinfo() output at: Loaded Configuration File

Add/replace this single line:
sendmail_path = /usr/bin/msmtp -t


Set up logging
mkdir /var/log/msmtp
chown www-data:adm /var/log/msmtp
nano /etc/logrotate.d/msmtp


Add these lines to the new file:
/var/log/msmtp/*.log {
  rotate 12
  monthly
  compress
  missingok
  notifempty
}


If you'd like to be able to view the logs as yourself, you should add yourself to the www-data group.


Full msmtp documentation: http://msmtp.sourceforge.net/documentation.html

Shiroka

Hallo!

Alleine schon der zweite Schritt scheiter schon .

Configure msmtp
Create a new configuration file at /etc/msmtprc with the following configuration information:

Nur schade das er das Verzeichnis msmtprc ist nach der Eingabe : apt-get install msmtp ca-certificates

nicht vorhanden ist ...

MfG Shiroka

Stefan1200

Quote from: Shiroka on July 19, 2016, 09:08:08 PM
Alleine schon der zweite Schritt scheiter schon .

Configure msmtp
Create a new configuration file at /etc/msmtprc with the following configuration information:

Nur schade das er das Verzeichnis msmtprc ist nach der Eingabe : apt-get install msmtp ca-certificates

nicht vorhanden ist ...

msmtprc ist kein Name von einem Verzeichnis, sondern der Name der Datei, die man erstellen soll.

Shiroka

#3
Okay wird msmtp nur durch den einen Befehlst installiert oder muss da noch mehr gemacht werden  ?  ???
*EDIT*
Ich habe es mir schon denken können , läuft jz ast rein !

FeritGang

Hallo kannst du mir Helfen bitte bei mir geht es auch nicht wenn sich user in JTS3ServerMod Registriert sendet kein email an registrierter user und der user hat dann keine zugangsdaten für den webinterfaces

Jack

Create a new configuration file at /etc/msmtprc with the following configuration information:

What does the file name need to be called, and do you put the selected code into that file, As I cannot get my Mail to work.

I'm also unsure of what to put in the Host & From in the next bit...

Stefan1200

#6
Quote from: Jack on June 16, 2017, 08:59:18 PM
Create a new configuration file at /etc/msmtprc with the following configuration information:

What does the file name need to be called

You posted your answer for your first question already in your post...

Host = your mail server
From = The mail address for the from field of the mail header.

But I can't give support for other programs, which are not created by me. I not even use msmtp, I just created this how to, because I got many questions about how to enable php mail support on linux. Please ask the msmtp support for further help related to this topic.

Jack

Quote from: Stefan1200 on June 16, 2017, 09:17:52 PM
Quote from: Jack on June 16, 2017, 08:59:18 PM
Create a new configuration file at /etc/msmtprc with the following configuration information:

What does the file name need to be called

You posted your answer for your first question already in your post...

Host = your mail server
From = The mail address for the from field of the mail header.

But I can't give support for other programs, which are not created by me. I not even use msmtp, I just created this how to, because I got many questions about how to enable php mail support on linux. Please ask the msmtp support for further help related to this topic.
I have managed to get the Mail Server now sending to my email and to peoples emails when I make them accounts, I just needed to install 2 things on my VPS Server to get it running, Thank you for the help :D

Pekka893

ich habe versucht alles so einzurichten wie in der Anleitung aber dann Funkt es nicht woran könnte es den Liegen?

Stefan1200

Keine Ahnung. Es gibt einfach zu viele verschiedene Web Server Dienste und Betriebssysteme. Aber vielleicht kann jemand anderes helfen. Ansonsten bitte Google verwenden oder den Programmierer von msmtp anschreiben.

ls13game

Schau mal in den Spam ordner hat bei mir mit PHPMail geklappt

h4zebust3r90

Hey,

Dachte mir das die Info vielleicht nützlich ist: Für den Versand per Gmail muss man vorher die IMAP Einstellungen aktivieren und unsicher Apps zulassen. Man bekommt von MSMTP den Hinweis mit einem Link.

Wenn dazu Fragen sind helfe ich gerne.

Jack

How would one go about doing this for windows?

Stefan1200

Quote from: Jack on July 17, 2018, 05:37:26 PM
How would one go about doing this for windows?

check php.ini file:
[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 = me@example.com

DanielK

Bei mir kommt immer noch ein "interener Fehler"