July 29th, 2005, 10:38 PM
Reading Email with PHP
Hey am working on a script and have hit a bit of a wall. I want to be able to update pages simply by sending an email to a specified POP enabled account (like gmail)
But have been unable to find any tutorials on how to accomplish this - the only thing that seems to come close is :
but as this seems to require the installation of an imap server on the machine you want to run the script on (and I am writing the script for use on my remotely hosted account not my local dev server) so this solution is not suitable.
Has anyone came across any tutorials on this or can they point me at least in the right direction....I've tried searching but I guess am not using the correct terms as nothing is coming up
July 31st, 2005, 08:20 PM
I simply love php with its boundless possibilities
They way to accomplish your request is by using
the php-imap facility, the same as mentioned
in the article you linked. It does allow you to talk
POP3 as well! Note, there is no need for an IMAP server,
the library simply has to be loaded. The php manual is
quite descriptive. If you cannot use this (see below
section configuration), check out this POP3-class based
on sockets (in german, but the script is self-explaining.
I have not tested it, however!).
But since I already do, what you want to do, here a
short excerpt of some script of mine.
A few thoughts, nevertheless:
exit("php_imap.dll not loaded!");
echo "php_imap.dll loaded!<br><br>\n";
exit("Could not connect!");
echo "Number of Mails: ".@imap_num_msg($mbox)."<br><br><hr><br><br>\n";
for ($i = 1; $i <= @imap_num_msg($mbox); $i++)
$header = @imap_headerinfo($mbox, $i,80,80);
echo "From: ".$header->from->mailbox."@".$header->from->host."<br>\n";
echo "Subject: ".$header->fetchsubject."<br>\n";
$body = @imap_body($mbox, $i);
echo $body."<br><br>\n<hr width=\"50%\"><br><br>\n";
echo "Connection successfully terminated!";
echo "Error in closing connection!";
Either use 'dl("php_imap.dll")' (here: windows, if
not multithreaded, and in case you cannot alter the php.ini file (remote server)),
or (let) untag in the php.ini file the line
or corresponding to your OS.
Since you plan to perform maintenance via email, be careful what you
allow to do. My best suggestion is to actually sign the emails you send
to that pop-account with your private key, in order to let php verify the
integrity and authenticity of the message (ie the body of the email). Make
sure to add some "salt" to the message In addition, I would also limit
the size of allowed emails.
Please note, that I do delete downloaded mails by closing the connection
using the CL_EXPUNGE flag.
/edit: Of course, parts of the code are copied one-to-one from php.net-comments
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)
August 1st, 2005, 02:16 AM
ah sec you've come up with the goods again
thanks matey - will take a look at the info you've provided (And the script) see what I come up with
oh and if i could i would
You must spread your AntiPoints around before giving it to sec_ware again.