[Tutor] email content-type: text/plain
Python
python at venix.com
Thu Nov 16 23:30:35 CET 2006
On Thu, 2006-11-16 at 15:57 -0600, shawn bright wrote:
> use MIMEText(message, 'someTypeThatIsn'tPlain') ? but type/plain is
> what i am after.
> i am a bit confused here. It defaults to plain, but there is not
> anything in the message headers that say what type it is. Should i use
> MIMEText(message, 'text/plain') ?
NO.
server.sendmail takes a list of recipients. So rather than specifying
msg['To'] for the recipients, use
[address,'youremail at someisp.net']
You'll see exactly what you are sending. My emails that get sent with
Python code pretty much like yours have the proper MIME tag:
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Do you have access to the server log files? Could something else be
going wrong?
My (works with email to text messaging and paging services) code:
import urllib, urllib2, smtplib, pprint
import email.MIMEText as MIMEText
(snipped the dull parts)
msg = MIMEText.MIMEText(msg_text)
if subject:
msg['Subject'] = subject
msg['From'] = from_addy
# to_addy is a list of recipients
msg['To'] = ','.join(to_addy)
server = smtplib.SMTP( mail_server)
server.sendmail( from_addy, to_addy, msg.as_string())
server.close()
>
> thanks
> sk
>
> On 11/16/06, Chris Hengge <pyro9219 at gmail.com> wrote:
> Not sure if I'm really helping, but I want to try for all the
> help I've gotten...
> I took this from: http://docs.python.org/lib/module-
> email.message.html
> ##############################################################################
> class MIMEText(
> _text[, _subtype[, _charset]])
> Module: email.mime.text
>
> A subclass of MIMENonMultipart, the MIMEText class is used to
> create MIME objects of major type text. _text is the string
> for the payload. _subtype is the minor type and defaults to
> plain. _charset is the character set of the text and is passed
> as a parameter to the MIMENonMultipart constructor; it
> defaults to us-ascii. No guessing or encoding is performed on
> the text data.
>
> #############################################################################
>
> Going off this, I'd say you need to change:
>
> msg = MIMEText(message)
>
>
> to:
>
> msg = MIMEText(message, 'someTypeThatIsn'tPlain')
>
> On 11/16/06, shawn bright <nephish at gmail.com> wrote:
> hey there all,
> i am using the email package and the phone provider i
> am trying to get a text message thru has sent me an
> email that says that they are looking for a tag that
> says 'content-type text/plain'
>
> i have tried about everything i can think of to get it
> in there, but everything i have tried has failed.
>
> here is what i have so far:
> address = 'someplace at someplace.com'
> message = 'some text that needs to be delivered via
> text message'
> msg = MIMEText
> (message)
> msg['Subject'] = 'pivots'
> msg['From'] = 'l11 at xit.net'
> msg['To'] = address
> server.sendmail(msg['From'],msg['To'], msg.as_string
> ())
>
> any ideas ?
> thanks
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
--
Lloyd Kvam
Venix Corp
More information about the Tutor
mailing list