Site layout and content has been updated. All sections except the Photogallery now use the new layout
scripts.suramya.com -> Web2Email
Web2EmailWeb2Email is a Perl Script that uses wkhtmltopdf to convert websites sent to it via email to PDF's and sends them back to the sender.
I created this script because at times I am behind a firewall where I can't access a site and this gives me a wey to get the content of the site as an email. The first version was created in about 2 hours of coding, and is very basic so doesn't have any validations/error checking etc. I will be adding them soon, but the script does work without it so you can download it and use it.
- Suramya
Download Web2Email Ver 0.1 from here
The first thing you need is an email address that will recieve the emails to be processed by Web2Email. I would recommend that you use an IMAP account because the current script connects to the mail server using IMAP. However if you want you can also use POP3 to connect, but that will require you to change the code a bit.
Perl Modules
In order to use this script you need to have the following Perl Modules installed:
o Net::IMAP::Simple
o String::Random
o MIME::Lite
Installing the Perl Modules:
The easiest way to install the modules is to use the CPAN module. Run the following commands as root:
o cpan -i Net::IMAP::Simple
o cpan -i String::Random
o cpan -i MIME::Lite
If you don't have CPAN installed (I highly recommend installing it if you don't) download the modules from the CPAN website and install them manually (Instructions in the INSTALL file included in each module).
Install wkhtmltopdf
To install wkhtmltopdf on a Debian system run the following command as root:
apt-get install wkhtmltopdf
- Download the latest version of Web2Email from the Download section above.
- Extract Web2Email from the Web2Email_vx.y.tar.gz where x.y identifies the version no. The current version is 0.1
tar -zxvf Web2Email_v0.1.tar.gz
- Make the script executable using the command:
chmod a+x Web2Email.pl
Once you finish the steps above all you need to do is configure Web2Email and you are done.
Open the script in your favorite editor and change the following variables:
$ServerName
This variable contains the name of the IMAP Server which the script will use.
$SMPTServer
This variable contains the name of the SMTP Server which the script will use.
$EmailAddress
This variable contains the Email address where the reply's come from.
$UserName
This variable contains the Username to authenticate to the IMAP & SMTP Server
$Password
This variable contains the Password to authenticate to the IMAP & SMTP Server.
This script basically checks the email server (You can easily put it in a loop, or put it in cron as I have done) and process any new mails found and then exits. Before running the script, make sure that you have configured the script with the correct authentication information as specified in the previous section.
To start the script issue the following command in the directory where you extracted the script:
./Web2Email.pl
Once the script is running, all you need to do is send an email to the account you configured in the script. The body of the email shoulf contain the URL's that you want to snapshot (one per line). All URL's in the mail will be processed and the resulting pdf will be sent back to the sender.
When you send the email, after a little while you will recieve an email with the website snapshot as a PDF attachment. You can see a sample PDF created for Google.com here.
I am interested in hearing about any projects that you might build based on this article so if you have an interesting project idea do contact me.
- Suramya
20th Sept 2011