Mam problem ze skonfigurowaniem poprawnym funkcji mail. Zainstalowałem w systemie sendmaila:
sudo apt-get install sendmail
Zmieniłem zawartość pliku php.ini:
[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
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = /usr/sbin/sendmail -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 = On
; 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 =
Efekt wykonania poniższego skryptu jest pozytywny, ale e-mail nie dochodzi.
if(mail('mojadres@gmail.com', 'info michal', 'Tekst wiadomosci\r\n', 'From: michal@domena.pl'))
echo 'OK!'; // zawsze to :/
else
echo 'Błąd!';
?>
Podejrzewam że kwestią jest zła konfiguracja sendmaila, czy zna ktoś jakieś poradniki najlepiej w języku pl odnośnie tego programu. Tzn. podstawowe opcje i sposoby konfiguracji?
PS: Dodam że ów skrypt znajduje się na moim Ubuntu z zainstalowanym apache, a nie na jakimś tam hostingu.
May 5 13:05:49 michal sm-mta[2520]: p41EJdI5004735: to=, ctladdr= (33/33), delay=3+20:46:10, xdelay=00:00:00, mailer=esmtp, pri=9660396, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
May 5 13:05:49 michal sm-mta[2520]: p41EPiEh004973: to=, ctladdr= (33/33), delay=3+20:40:05, xdelay=00:00:00, mailer=esmtp, pri=9660399, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
May 5 13:05:49 michal sm-mta[2520]: p41EFG3a004629: to=, ctladdr= (33/33), delay=3+20:50:33, xdelay=00:00:00, mailer=esmtp, pri=9750395, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
May 5 13:05:49 michal sm-mta[2520]: p41EFSIS004648: to=, ctladdr= (33/33), delay=3+20:50:20, xdelay=00:00:00, mailer=esmtp, pri=9750395, relay=alt4.gmail-smtp-in.l.google.com., dsn=4.0.0, stat=Deferred: Connection timed out with alt4.gmail-smtp-in.l.google.com.
May 5 13:14:43 michal sm-mta[2713]: p4594wqR005544: timeout waiting for input from gmail-smtp-in.l.google.com. during client greeting
May 5 20:38:01 michal sm-mta[1221]: starting daemon (8.14.4): SMTP+queueing@00:10:00
May 5 20:38:01 michal sm-mta[1222]: p459A1bq005592: p45Ic1uA001222: sender notify: Warning: could not send message for past 4 hours
May 5 20:38:04 michal sm-mta[1222]: p45Ic1uA001222: to=, delay=00:00:03, xdelay=00:00:02, mailer=local, pri=30000, dsn=2.0.0, stat=Sent
Reszta plików jest pusta. Logi zapisały się po restarcie. Wkleiłem kilka ostatnich pozycji. Wszystkie są identyczne z wyjątkiem trzech ostatnich wierszy które również wkleiłem.