473,569 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need help with nullmailer-inject in python cgi script to send attachements ?

Due to the restrictions I have at my host, I cannot use smtplib in my
email cgi script. They gave me a script they use that calls
nullmailer-inject. I am trying to figure out how to add the ability
to send attachments via the nullmailer-inject call. I could not find
much documentation on google about nullmailer. Has anyone used it
before to send attachments? Here is function I have so far that
sends a regular email. The variables like recipient are set from a cgi
in another part of the script.

thanks

Ty

def genmail(reql):
if nosend: return
recip=recipient
cap=form.keys()
cap.sort()
mailfl=os.popen ('/usr/bin/nullmailer-inject -f '+fromaddr,'w')
mailfl.write('T o: '+recipient+nl)
if fromaddr: mailfl.write('F rom: '+fromaddr+nl)
mailfl.write('S ubject: %s%s\n\n'%(subj ect,uri))
mailfl.write(in tro)
rx=0
prev=''
for x in cap:
while (rx<len(reql) and reql[rx]<x):
if reql[rx]<>prev:
putln(reql[rx],mailfl)
rx=rx+1
putln(x,mailfl)
prev=x

for x in envl:
mailfl.write('% s: %s\n'%(x,env[x]))
mailfl.close()

Jul 18 '05 #1
2 2474
On 24 Mar 2005 05:20:06 -0800 tv****@gmail.co m wrote:

TC> Due to the restrictions I have at my host, I cannot use smtplib in
TC> my email cgi script. They gave me a script they use that calls
TC> nullmailer-inject. I am trying to figure out how to add the
TC> ability to send attachments via the nullmailer-inject call. I could
TC> not find much documentation on google about nullmailer. Has anyone
TC> used it before to send attachments? Here is function I have so
TC> far that sends a regular email. The variables like recipient are
TC> set from a cgi in another part of the script.
[...]
TC> mailfl=os.popen ('/usr/bin/nullmailer-inject -f '+fromaddr,'w')
TC> mailfl.write('T o: '+recipient+nl)
TC> if fromaddr: mailfl.write('F rom: '+fromaddr+nl)
TC> mailfl.write('S ubject: %s%s\n\n'%(subj ect,uri))
TC> mailfl.write(in tro)
TC> rx=0
TC> prev=''
TC> for x in cap:
TC> while (rx<len(reql) and reql[rx]<x):
TC> if reql[rx]<>prev:
TC> putln(reql[rx],mailfl)
TC> rx=rx+1
TC> putln(x,mailfl)
TC> prev=x
TC>
TC> for x in envl:
TC> mailfl.write('% s: %s\n'%(x,env[x]))
TC> mailfl.close()

Use email package. Something like the following (untested):

from email.MIMEText import MIMEText
msg = MIMEText(body)
msg['Subject'] = ...
msg['From'] = ...
msg['To'] = ...

from email.MIMEBase import MIMEBase
attachment = MIMEBase('appli cation', 'octet-stream')
attachment.set_ payload(open(fi lename, 'rb').read())
attachment.add_ header('Content-Disposition', 'attachment',
filename=filena me)
from email.Encoders import encode_base64
encode_base64(a ttachment)
msg.attach(atta chment)

# using popen is unsafe if we can't trust fromaddr, using subprocess
from subprocess import Popen, PIPE
mailfl = Popen(['/usr/bin/nullmailer-inject', '-f', fromaddr],
stdin=PIPE)
mailfl.stdin.wr ite(msg.as_stri ng())
mailfl.stdin.cl ose()
mailfl.wait()

--
Denis S. Otkidach
http://www.python.ru/ [ru]
Jul 18 '05 #2
Thank you Denis

Ty

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
3664
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit cumbersome to always include std. I somewhere found a trick to overcome this problem. By using using std::cout;
9
2914
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with a device. The definition of the table is as follows: CREATE TABLE devicedata ( device_id int NOT NULL REFERENCES devices(id), -- id in the...
3
10623
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays...
4
7391
by: Phil | last post by:
k, here is my issue.. I have BLOB data in SQL that needs to be grabbed and made into a TIF file and placed on the client (could be in temp internet dir). The reason we need it in TIF format is there are multiple pages per invoice. How can I grab the data, make the TIF, place it on the client and then Open with the clients default program...
8
1821
by: Sai Kit Tong | last post by:
In the article, the description for "Modiy DLL That Contains Consumers That Use Managed Code and DLL Exports or Managed Entry Points" suggests the creation of the class ManagedWrapper. If I need to build multiple mixed mode dll's used by a consumer application, do I have to implement multiple ManagedWrapper's (each embedded in indiviudal...
2
1940
by: Michael R. Pierotti | last post by:
Dim reg As New Regex("^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$") Dim m As Match = reg.Match(txtIPAddress.Text) If m.Success Then 'No need to do anything here Else MessageBox.Show("You need to enter a valid IP Address", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Hand) txtIPAddress.Focus() Return End If
5
2934
by: HotRod | last post by:
I am new to this so please go easy. We currently have some students doing some work on some web based tracking documents for us. They are currently using VB .net to develop what we requested. Anyway I've been calling my local ISP's and no one supports .net it seems to be all apache and MySQL. I'm wondering if everyone here can answer a few...
10
2562
by: L. R. Du Broff | last post by:
I own a small business. Need to track a few hundred pieces of rental equipment that can be in any of a few dozen locations. I'm an old-time C language programmer (UNIX environment). If the only tool you know how to use is a hammer, every problem tends to look like a nail. That said, I could solve my problem in C, but it's not the right...
15
4578
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never...
23
2518
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.