Mau aplikasi PHP kamu bisa mengirim email walaupun kamu menjalankannya di localhost dengan OS Windows? Mau tau caranya? silahkan teruskan membacanya
.
Untuk mengirim email menggunakan fungsi mail dari localhost yang perlu dilakukan adalah mengubah konfigurasi PHP (file php.ini) pada bagian [mail function] seperti berikut.
[mail function] ; For Win32 only. ;SMTP = localhost ;smtp_port = 25 ; For Win32 only. ;sendmail_from = webmaster@localhost ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = ; 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 =
Syarat untuk melakukan perubahan ini adalah kamu harus punya smtp server. Bagaimana jika tidak punya? Jika kamu punya website, kamu bisa menggunakan smtp server website kamu, misalnya mail.domain-anda.tld. Pada bagian SMTP ganti nilai localhost dengan mail server kamu, misalnya mail.domain-anda.tld, sedangkan pada bagian smtp_port ganti dengan port smtp server kamu, standarnya 25. Jangan lupa uncomment kedua baris tersebut dengan menghapus tanda titik koma (;) sehingga setingannya akan seperti berikut.
[mail function] ; For Win32 only. SMTP = mail.domain-anda.tld smtp_port = 25 ; For Win32 only. ;sendmail_from = webmaster@localhost ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ;sendmail_path = ; 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 =
Simpan dan restart apache kamu dan selamat mencoba. Saya sendiri sudah mencobanya dan berhasil.
Cara yang lain yang bisa digunakan untuk mengirim email menggunakan php mail dari windows adalah dengan menggunakan fake sendmail yang dibuat oleh Byron Jones. Fake sendmail mirip dengan sendmail pada linux. Pertama unduh fake sendmail untuk windows di sini atau di sini, kemudian ekstrak. Lalu buka file sendmail.ini dengan text editor, kemudian cari baris smtp_server, smtp_port. Ganti nilai smtp_server, smtp_port dengan smtp server dan smtp port website kamu. Contohnya seperti berikut.
[sendmail] ; you must change mail.mydomain.com to your smtp server, ; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup) ; emails delivered via IIS's pickup directory cause sendmail to ; run quicker, but you won't get error messages back to the calling ; application. smtp_server=mail.domain-anda.tld ; smtp port (normally 25) smtp_port=25
Kemudian ubah konfigurasi PHP (php.ini) pada bagian [mail function] pada baris sendmail_path. Isi nilai sendmail_path dengan “path\to\sendmail.ext -t”. Misalkan kamu menyimpan file sendmail.exe pada folder C:\sendmail\sendmail.exe maka isikan “C:\sendmail\sendmail.exe -t” pada sendmail_path. Contohnya sebagai berikut.
[mail function] ; For Win32 only. ;SMTP = localhost ;smtp_port = 25 ; For Win32 only. ;sendmail_from = webmaster@localhost ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = "C:\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 =
Kemudian restart apache dan siap untuk dicoba.
Dengan menggunakan fake sendmail kamu bisa menggunakan smtp server nya google asalkan kamu punya account google mail (gmail). Caranya ubah nilai smpt_server menjadi smtp.gmail.com, smtp_port menjadi 587 dan juga pada baris auth_username dan auth_password isi dengan email dan password gmail kamu. Contoh konfigurasinya seperti berikut.
[sendmail] ; you must change mail.mydomain.com to your smtp server, ; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup) ; emails delivered via IIS's pickup directory cause sendmail to ; run quicker, but you won't get error messages back to the calling ; application. smtp_server=smtp.gmail.com ; smtp port (normally 25) smtp_port=587 ; the default domain for this server will be read from the registry ; this will be appended to email addresses when one isn't provided ; if you want to override the value in the registry, uncomment and modify ;default_domain=mydomain.com ; log smtp errors to error.log (defaults to same directory as sendmail.exe) ; uncomment to enable logging error_logfile=error.log ; create debug log as debug.log (defaults to same directory as sendmail.exe) ; uncomment to enable debugging ;debug_logfile=debug.log ; if your smtp server requires authentication, modify the following two lines auth_username=youremail@gmail.com auth_password=password
Selamat mencoba, jika berhasil selamat ya, jika gagal mungkin ada yang salah dengan konfigurasinya atau kamu belum terhubung dengan internet, silahkan diperiksa dan dicoba lagi
28 Comments to “Mengirim email menggunakan php mail dari localhost”
Post comment
Tulisan Terakhir
- Taqobalallahu mina wa minkum
- Install Nginx menggunakan Nginxcp
- Error Install PHP Mongo Extension
- Cek Apakah Nilai Sebuah Field di Tabel MySQL, Integer Atau Bukan
- WordPress dan PHP 5.3, Permalink Page Blank
Arsip
- September 2011
- Juni 2011
- Mei 2011
- Maret 2011
- Agustus 2010
- Mei 2010
- Januari 2010
- Februari 2009
- Desember 2008
- September 2008
- Agustus 2008
- Juli 2008
- Juni 2008
- April 2008
- Maret 2008
- Februari 2008
- Januari 2008
Blogroll
- Batik Murah
- Buat Blog
- Cara Buat Blog
- Cara Membuat Blog
- Endoet
- Hosting Murah Indonesia
- Iklan Baris Gratis
- Iklan Gratis
- Iklan Gratis
- Membuat Blog
- Pusat Promosi
- Website Murah
Komentar Terakhir
- kocu pada Submit form sederhana dengan ajax menggunakan mootools
- nanang pada Plugin-plugin JQuery Yang Layak Dicoba
- elyosfimuchlis pada Plugin-plugin JQuery Yang Layak Dicoba
- mruteck pada Plugin-plugin JQuery Yang Layak Dicoba
- joinonptc pada Plugin-plugin JQuery Yang Layak Dicoba


Barayuda says:
Ou.. gebono toh mas caranya.
thx u ilmu nya mas..