Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:02:12+00:00 2026-06-12T04:02:12+00:00

def sendmail(self, from_addr, to_addrs, msg=’hello’, mail_options=[],rcpt_options=[]): self.ehlo_or_helo_if_needed() esmtp_opts = [] if self.does_esmtp: # Hmmm?

  • 0
    def sendmail(self, from_addr, to_addrs, msg='hello', mail_options=[],rcpt_options=[]):
            self.ehlo_or_helo_if_needed()
            esmtp_opts = []
            if self.does_esmtp:
                    # Hmmm? what's this? -ddm
                    # self.esmtp_features['7bit']=""
                    if self.has_extn('size'):
                                esmtp_opts.append("size=%d" % len(msg))
                    for option in mail_options:
                            esmtp_opts.append(option)

            (code, resp) = self.mail(from_addr, esmtp_opts)
            if code != 250:
                self.rset()
                #raise SMTPSenderRefused(code, resp, from_addr)
            senderrs = {}
            if isinstance(to_addrs, basestring):
                to_addrs = [to_addrs]
            for each in to_addrs:
                (code, resp) = self.rcpt(each, rcpt_options)
                if (code != 250) and (code != 251):
                    senderrs[each] = (code, resp)
            if len(senderrs) == len(to_addrs):
                # the server refused all our recipients
                self.rset()
                #raise SMTPRecipientsRefused(senderrs)
            (code, resp) = self.data(msg)
            if code != 250:
                self.rset()
                #raise SMTPDataError(code, resp)
            #if we got here then somebody got our mail
            return senderrs

I am trying to build my own smtplib.I am getting TypeError: ‘NoneType’ object is not iterable when i try
(code, resp) = self.data(msg)

self.data() is defined as-
I am using self.data() to put the message to the server.

    def data(self, msg):
            self.putcmd("data")
            (code, repl) = self.getreply()
            if self.debuglevel > 0:
                    print>>stderr, "data:", (code, repl)
            if code != 354:
                    #raise SMTPDataError(code, repl)
                    print "Err"
            else:
                    q = quotedata(msg)
                    if q[-2:] != CRLF:
                            q = q + CRLF
                    q = q + "." + CRLF
                    self.send(q)
                    (code, msg) = self.getreply()
                    if self.debuglevel > 0:
                            print>>stderr, "data:", (code, msg)
                    return (code, msg)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:02:13+00:00Added an answer on June 12, 2026 at 4:02 am

    We can’t tell from the code that you have posted what self.data() is doing, but it is clear from your error that it is returning None. If you try to unpack None, you get this:

    >>> (code, resp) = None
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'NoneType' object is not iterable
    

    Posting the code for self.data() might help.

    Update after extra code posted:

    The code (code, repl) = self.getreply() could also be unpacking None [note: there are two instances of this in self.data()]. Is the exception raised in self.data() or in sendmail()?

    Also

    if code != 354:
                #raise SMTPDataError(code, repl)
                print "Err"
    else:
        ...
    

    If you get code 354, you have commented out the raise and the function now returns None. That might also be the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is the method to send mail by python program. def Send_Mail(self, username, password,
This is my code: class EmailThread(threading.Thread): def __init__(self, subject, html_content, recipient_list): self.subject = subject
I have the next code: def send_email(self, alert_emails, subj, msg): global alert_from p =
def self.jq_column_models COLUMN_NAME.collect {|x| {:name => x.to_s, :width => 80, :format => 'integer' if
def self.get(server) return unless server server = server.to_s if klass = @handlers[server] obj =
I have a method that generates a PDF file using Reportlab library: def obtenerPDFNuevoPedido(self,
I want to test this view: def register(request): handle user registration code variable is
This is my normal code in my VPS hosting which provide python 2.4 def
def download_if_dne(href, filename): if os.path.isfile(filename): # print 'already downloaded:', href return False else: if
def On_Instrumentation_StartAnimation(): Syntax : On_Instrumentation_StartAnimation() Purpose : Fired if the animation is started Parameters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.