User avatar
DougieLawson
Posts: 38863
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Using windows software

Tue Jun 24, 2014 10:54 pm

sudo apt-get install exim4 exim4-base exim4-config exim4-daemon-light heirloom-mailx

or

sudo apt-get install postfix

Pick your poison.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

piff
Posts: 10
Joined: Mon Jun 23, 2014 1:59 pm

Re: Using windows software

Wed Jun 25, 2014 9:55 am

hi again,

I found this script for python

Code: Select all

#!/usr/bin/python
 
# Import smtplib for the actual sending function
import smtplib
 
# For guessing MIME type
import mimetypes
 
# Import the email modules we'll need
import email
import email.mime.application
 
#Import sys to deal with command line arguments
import sys
 
# Create a text/plain message
msg = email.mime.Multipart.MIMEMultipart()
msg['Subject'] = 'subject_you_prefer'
msg['From'] = 'senders_mail@gmail.com'
msg['To'] = 'receivers_mail@gmail.com'
 
# The main body is just another attachment
body = email.mime.Text.MIMEText("""Here you can write as many things as you want!""")
msg.attach(body)
 
# PDF attachment block code
 
directory=sys.argv[1]
 
# Split de directory into fields separated by / to substract filename
 
spl_dir=directory.split('/')
 
# We attach the name of the file to filename by taking the last
# position of the fragmented string, which is, indeed, the name
# of the file we've selected
 
filename=spl_dir[len(spl_dir)-1]
 
# We'll do the same but this time to extract the file format (pdf, epub, docx...)
 
spl_type=directory.split('.')
 
type=spl_type[len(spl_type)-1]
 
fp=open(directory,'rb')
att = email.mime.application.MIMEApplication(fp.read(),_subtype=type)
fp.close()
att.add_header('Content-Disposition','attachment',filename=filename)
msg.attach(att)
 
# send via Gmail server
# NOTE: my ISP, Centurylink, seems to be automatically rewriting
# port 25 packets to be port 587 and it is trashing port 587 packets.
# So, I use the default port 25, but I authenticate.
s = smtplib.SMTP('smtp.gmail.com:587')
s.starttls()
s.login('senders_mail@gmail.com','the_password_of_the_senders_mail')
s.sendmail('receivers_mail@gmail.com',['receivers_mail@gmail.com'], msg.as_string())
s.quit() 
i am runing it using IDLE 3 and i get this error :
AttributeError: 'module' object has no attribute 'Multipart'

?! how can i correct it?

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: Using windows software

Wed Jun 25, 2014 5:25 pm

I tested it last time on Python 2.5 so use IDLE 2 not 3.

elatllat
Posts: 1337
Joined: Sat Dec 17, 2011 5:05 pm

Re: Using windows software

Fri Oct 03, 2014 3:40 am

DougieLawson wrote:Use this code...
That is a lot of code compared to say this:

Code: Select all

curl myip.dnsdynamic.org
SBC with 32GB RAM: https://hardkernel.com

FAQ : https://raspberrypi.stackexchange.com

Unanswered: https://www.raspberrypi.org/forums/search.php?search_id=unanswered

Return to “Beginners”