Note that there are some explanatory texts on larger screens.

plurals
  1. POError in email sending during testcase in django?
    text
    copied!<p>I have a simple django application which allows users to add a new user.Whenever we created a new user,a mail will send to that respective email-id (what we gave while creating a new user).If i have added any new user with email say xxxx@xxxx.com,a mail will send succesfully to xxxx@xxxx.com.I have no problem here.</p> <p>But when I try to write a testcase for adding a new user, I got error in email sending line in my code...ie <code>TypeError: __init__() takes at most 2 non-keyword arguments (6 given)</code>. The code is given below,</p> <pre><code>#from my views.py, Email().send_email(settings.FORGOT_SUBJECT, emailmessage, [username], settings.CONTENT_TYPE)` </code></pre> <p>pls remember i have no problem in this line while created a user from webpage &amp; the mail send sucesfully.only getting error in this line during testcase.</p> <pre><code># code for SMTP connection class Email: def __init__(self): return; def send_email(self, subject, message, recipients, contenttype): """ Send email using smtp connection. """ try: from django.core.mail import EmailMessage, SMTPConnection, send_mail from settings import EMAIL_HOST, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD, EMAIL_PORT, EMAIL_USE_TLS finally: connection = SMTPConnection(EMAIL_HOST, EMAIL_PORT, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD, EMAIL_USE_TLS) emailMessage = EmailMessage(subject, message, settings.EMAIL_HOST_USER, recipients) emailMessage.content_subtype = contenttype connection.send_messages([emailMessage]) </code></pre> <p>Pls give any solution to avoid this error.</p> <pre><code>TypeError: __init__() takes at most 2 non-keyword arguments (6 given) </code></pre> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload