Saturday, July 27, 2024
HomeDeveloperHow to catch emails sent with PHP on your local server

How to catch emails sent with PHP on your local server

Date:

Related stories

Play Crazy Time and Win Big

Crazy Time is an exciting live casino game that...

Exploring the Excitement of Online Gaming: A Comprehensive Guide

Online gaming has rapidly evolved into one of the...

Starzbet APP: Features and User Experience

In the rapidly evolving landscape of online betting, accessibility...

Hassle-Free Starzbet Giriş: Start Betting Instantly

Starzbet Giriş, or login, is your gateway to a...

Get the Latest Updates on Starzbet Twitter

In the fast-paced world of online gaming and betting,...
spot_img

First, create a folder for your outgoing mail. We will create it in under /var/log/ where all the logs are stored:

$ sudo mkdir /var/log/mail

Create file /usr/local/bin/sendmail using your favorite text editor, I normally use Nano editor:

$ sudo nano /usr/local/bin/sendmail

Add following PHP script to this new “sendmail” file:

#!/usr/bin/php
<?php
$input = file_get_contents('php://stdin');
preg_match('|^To: (.*)|', $input, $matches);
$filename = tempnam('/var/log/mail', $matches[1] . '.');
file_put_contents($filename, $input);

This is where the magic happens and emails sent from PHP are stored as textfiles. The email address is extracted from the full email using regular expression, and used as the filename base – the tempnam() function creates a random filename with the email address used as filename prefix. You can alter this part however you want, for example include a timestamp in the filename.

We need to link our PHP script to PHP’s sendmail functionality. Edit your php.ini file and set the sendmail_path setting as following:

sendmail_path = /usr/local/bin/sendmail

If you use Ubuntu/Kubuntu 12.4, your php.ini file is normally located at /etc/php5/apache2/php.ini. You can find your php.ini location also using the phpinfo() function, where you look for “Loaded Configuration File” value in the function’s output.

Now we need to set permissions for new files/folders:

$ sudo chmod 755 /usr/local/bin/sendmail
$ sudo chmod 777 /var/log/mail

Restart apache:

$ sudo /etc/init.d/apache2 restart

And that’s it! You can now try to send an email using PHP’s mail() function and check the /var/log/mail folder.

Latest stories

spot_img
sabung ayam online
slot mahjong
akun pro jepang
https://sipita.akmt.ac.id/ttd/jmw/
https://akmt.ac.id/wp-content/plugins/cas/
https://akmt.ac.id/wp-content/plugins/caq/
https://sta-afc-ob.com/wp-content/uploads/2020/
https://sta-afc-ob.com/wp-content/uploads/2020/xgacor/
http://unitycolleges.co.in/1_2_1/terbaru/
https://diabeticregulator.com/images/joker/
https://kodimariimpex.com/img/slot-online/
https://mynasolutions.com/includes/gampang-menang/
https://perpustakaan.ithb.ac.id/files/chat/
https://gosyensejahterautama.co.id/core/vendor/split/
https://gosyensejahterautama.co.id/core/vendor/lan/
https://lp2m.akmt.ac.id/-/xgacor/
https://phys.unpad.ac.id/wp-content/languages/
https://mbig.bakrie.ac.id/config/-/max/
https://mbig.bakrie.ac.id/error/-/xbitxx/
https://ma.arrahmat-majalengka.sch.id/lib/ws168/
https://ma.arrahmat-majalengka.sch.id/lib/mix/
https://elearning.smpn2jayapura.sch.id/-/xgacor/
https://event.potensiaskill.com/defe/
https://event.potensiaskill.com/ceo/
https://blueedenscraptrading.com/zuu/
https://infinitotravel.com.ar/
https://laotomana.com.ar/
https://portal.stiemadani.ac.id/vendor/lib/mix/
https://portal.stiemadani.ac.id/vendor/lib/hitam/
TANGKASNET/
AKUN PRO PLATINUM
https://rajawalitanjungsari.com
sv388
casino online
agen sbobet
sabung ayam online
mahjong ways 2
scatter hitam
slot thailand
slot thailand
indobola77
indobola77
sabung ayam online
slot777
slot gacor
indomax88
indomax88
slot gacor
bandar303
bandar303
bandar303
Juara303
indobit88
master303 slot
master303 slot
Scatter Hitam
sabung ayam online
slot gacor
bola gacor
akun pro thailand
Sabung Ayam Online
Slot777
Ws168
https://sma1polanharjo.sch.id/
Casino Online
https://realcount-bundaenie.com/
https://operator-bsnpgkotabekasi.com/
https://bsnpgkotabekasi.com/
slot thailand
sv388
sabung ayam online
sv388
sabung ayam online
slot gacor
slot zeus
https://ela.p3tik.unisma.ac.id/
sbobet
sv388
sbobet
Zeus Slot
Akun Jp
Zeus Slot
Slot Thailand
Scatter Hitam
Slot777
Sv388
Akun Demo Slot