Copy Link
Add to Bookmark
Report

NULL mag Issue 05 18 You've got netmail

eZine's profile picture
Published in 
null magazine
 · 3 years ago

  

__ _ __ _ _ __
______\ \_\\_______________________\///__________________________//_/ /______
\___\ /___/
| .__ __ |
| | ___ __________/ |________ |
| \ \/ / ____/\ __\_ __ \ |
; > < <_| | | | | | \/ ;
: /__/\_ \__ | |__| |__| :
. \/ |__| .
. .
: H/Q Another Droid BBS - andr01d.zapto.org:9999 :
; ;
+ --- -- - . - --- --- --- - . - -- --- +
: :
| You've got Netmail |
: :
` --- -- - . - --- --- --- - . - -- --- '

This is almost the same script as in the other tutor, about finding changes
in files. The only difference is that, instead of checking a hash
string, we check the size of the file... and even better, we check the
number of messages a JAM base, like Netmail, contains.

A JAM Base is a combination of 4 files. One of them is the Index File.
This file contains a record of 8 bytes size, for each message the base
has. So if we divide the file size of the Index file with 8, which is
the size of the record we get the number of messages the base
contains. Easy ;)

So we use the same script, but instead of storing and checking the
hash string, we store the number of records the base has.

Make sure to edit the correct values.

+ --- -- - . - --- --- --- - . - -- --- '

#!/usr/bin/python
import smtplib
from sys import argv
import os


to_ = 'receiver@mail.com'
subject = 'File Changed...'
text = 'You have got a new mail? perhaps?'
hash_file = './oldhash.txt' # Store old hash. This file must exist
old_hash = ''
new_hash = ''
base_file = './check' # The file to be checked. Must exit.

with open(hash_file) as f:
old_hash = f.readline()

new_hash = str(os.path.getsize(base_file) / 8)

if new_hash == old_hash :
print "Nothing changed. Exiting."
exit()

with open(hash_file, 'w') as fw:
fw.write(new_hash)
fw.close()

print "HASH Changed. Sending mail"

# Send email

# Gmail Sign In
gmail_sender = 'sender@mail.com'
gmail_passwd = 'password'

server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(gmail_sender, gmail_passwd)

BODY = '\r\n'.join(['To: %s' % to_,
'From: %s' % gmail_sender,
'Subject: %s' % subject,
'', text])

try:
server.sendmail(gmail_sender, [to_], BODY)
except:
print ('')

server.quit()

+ --- -- - . - --- --- --- - . - -- --- '
_____ _ _ ____ _ _
| _ |___ ___| |_| |_ ___ ___ | \ ___ ___|_|_| | 8888
| | | . | _| | -_| _| | | | _| . | | . | 8 888888 8
|__|__|_|_|___|_| |_|_|___|_| |____/|_| |___|_|___| 8888888888
8888888888
DoNt Be aNoTHeR DrOiD fOR tHe SySteM 88 8888 88
8888888888
/: HaM RaDiO /: ANSi ARt! /: MySTiC MoDS /: DooRS '88||||88'
/: NeWS /: WeATheR /: FiLEs /: SPooKNet ''8888"'
/: GaMeS /: TeXtFiLeS /: PrEPardNeSS /: FsxNet 88
/: TuTors /: bOOkS/PdFs /: SuRVaViLiSM /: ArakNet 8 8 88888888888
888 8888][][][888
TeLNeT : andr01d.zapto.org:9999 [UTC 11:00 - 20:00] 8 888888##88888
SySoP : xqtr eMAiL: xqtr@gmx.com 8 8888.####.888
DoNaTe : https://paypal.me/xqtr 8 8888##88##888

← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT