PHP: utilizzare la funzione mail() in locale con xampp e Windows 7 (Seven)

PHP: utilizzare la funzione mail() in locale con xampp e Windows 7 (Seven)

In un precedente articolo ho spiegato come configurare sendmail correttamente in Windows XP per poter utilizzare la funzione PHP mail() in locale.

Ora su Windows7 la configurazione non funziona più e per questo motivo ho dovuto cercare un’alternativa per risolvere velocemente il problema.

L’alternativa si chiama fake sendmail for windows . Ecco come configurare correttamente il programma:




1) scaricare il file zip dal sito http://glob.com.au/sendmail/ ed estrarre il contenuto

2) copiare i files nella cartella sendmail del proprio server locale (es. C:\xampp\sendmail\ )


3) aprire il file php.ini (solitamente in C:\xampp\php\php.ini ), cercare la stringa
1
[mail function]
e sostituire il blocco con questo (eventualmente correggendo il percorso del parametro sendmail_path che dovrà puntare al nuovo file sendmail.exe):


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
; 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 = postmaster@localhost
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
; 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 = Off
; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\apache\logs\php_mail.log"

4) a questo punto è sufficiente impostare i parametri del server smtp da utilizzare per l’invio nel file sendmail.ini . Questi sono i parametri da utilizzare per gmail:
1
2
3
4
5
6
7
8
9
smtp_server=smtp.gmail.com
smtp_port=25
smtp_ssl=auto
default_domain=gmail.com
error_logfile=error.log
;username e password
auth_username=USERNAME@gmail.com

Commenti

Post popolari in questo blog

Simulazioni di reti (con Cisco Packet Tracer)

Esercizi sulla rappresentazione della virgola mobile IEEE 754 (Floating Point)