Making PHP / WordPress send email using custom sendmail
Recently I have had the pleasure of migrating a WordPress website which resulted in a peculiar problem - sending email functionality on the new server no longer worked. After some digging around I found out that PHP has this mail function which uses the sendmail program to actually send your email.
Well after messing around with real sendmail for a good while and still not really understanding how to configure it properly, I decided to write my own sendmail.py script that uses my gmail and its app password to send out an email to whoever PHP/Wordpress wants to send an email to on my behalf.
After script was done I had to tell php to use it via sendmail_path = path to sendmail.py line inside php.ini which was located /etc/php5/apache2/php.ini on my Debian server. Then I just restarted apache server and voila, sending email worked!
Here is sendmail.py in all of its hacky glory:
#!/usr/bin/python
#this is replacement for sendmail that php can use to send its goddamn emails
import smtplib
import sys
def findToAddress(lines):
for i, val in enumerate(lines):
j = val.index("To: ")
if j != -1:
return val[j+4:]
return ""
fromaddr = 'whatever@example.com'
lines = sys.stdin.readlines()
toaddrs = findToAddress(lines)
msg = ''.join(lines)
username = 'you@gmail.com'
password = 'your app password'
# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:25')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr,toaddrs, msg)
server.quit()
My super secure password scheme
For the longest time in my life I have only used a single password for all the online services until I realized how much of a bad idea that is.
However I still didn't want to start memorizing a huge set of different passwords for each service so I came up with a following scheme which allows me to remember a single master password while still providing different password for each service. The key is in using a scheme that combines a master password plus the username and name of an online service then running resulting combination through a hash function output of which is what actually ends up being used as a password.
Running Backtrack 5 on my CR48
Back when Google was doing it's beta test program for Chrome Netbook, I applied and luckily received my own free CR48 laptop.
I have used Chrome OS for a while and while it's pretty good if you just always want to use chrome browser I was feeling a bit lonely without root access and gnome desktop. So I manned (nerded) up and flashed CR48 BIOS to allow running unsigned code and installed Backtrack 5 on it. Now CR48 is infinitely more usable and entertaining. All hardware (except 3g modem, I haven't gotten around to using that yet) works fine, and I didn't have to install any drivers manually. Only thing I had to do is create a non root user for use for desktop type tasks because by default Backtrack only has root user.
Create your own personal IM “cloud”!
Recently I have gotten around to purchasing my own VPS - Virtual Private Server. I did it because I wanted to have a server with root access on a pretty fast and reliable connection that I could use remotely from everywhere. One of the more useful things I have found to do on it is to run a chat client that I can use remotely from either web interface or SSH. What follows below is a high level description and instructions on how to setup your own IM "cloud"!