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 8048615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:29:55+00:00 2026-06-05T06:29:55+00:00

i have an activation mail sending script as follows. #!/usr/bin/python __author__ = ‘Amyth Arora

  • 0

i have an activation mail sending script as follows.

#!/usr/bin/python

__author__ = 'Amyth Arora (***@gmail.com)'

import smtplib
import string
import sys
import random

from email.MIMEText import MIMEText


def generate_activation_key(size=64, chars=string.ascii_lowercase + string.digits):
  return ''.join(random.choice(chars) for x in range(size))


def generate_activation_url(key):
  return 'http://www.example.com/users/activate/' + key

def Activate(name, to_addr):
  sender, reciever = 'mymail@gmail.com', to_addr
  act_url = generate_activation_url(generate_activation_key())
  main_mssg = """
  Dear %s,

  Thakyou for creating an account with Example.com. You are now just one click away from using your example account. Please click the following link to verify this email address and activate your account. 

  Please Note, You must complete this step to become a registered member of example. you will only need to visit this url once in order to activate your account.

  ============================
  Activation Link Below:
  ============================

  %s


  if you are facing problems activating your account please contact our support team at
  support@example.com

  Best Regards,

  Example Team
  """ % (name, act_url)


  message = MIMEText(main_mssg)
  message['From'] = 'Example <' + sender + '>'
  message['To'] = reciever
  message['MIME-Version'] = '1.0'
  message['Content-type'] = 'text/HTML'
  message['Subject'] = 'Activate Your Example Account'
  try:
    smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
    smtpObj.set_debuglevel(1)  # Swith On/Off Debug Mode
    smtpObj.ehlo()
    smtpObj.starttls()
    smtpObj.ehlo()
    smtpObj.login('mymail@gmail.com', 'mypass')
    smtpObj.sendmail(sender, reciever, message.as_string())
    smtpObj.close()
    return act_url
  except:
    return None

def main(argv):
  if len(argv) != 2:
    sys.exit(1)
  Activate(argv[0], argv[1])


if __name__ == '__main__':
  main(sys.argv[1:])

The script works fine as i have tried it through command line like this :

./scriptname 'Reciepent Name' 'reciepent@gmail.com'

however i want to call the activation script from within one of my application handlers like this.

import activation

act_key = activation.Activate('Reciepent Name', 'reciepent@gmail.com')

but when i do this the script returns None. Can anyone figure out how to fix this ?

  • 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-05T06:29:57+00:00Added an answer on June 5, 2026 at 6:29 am

    App Engine does not allow the users to send emails using the smtplib library. Instead you need to use the api provided. The documentation can be found here: https://developers.google.com/appengine/docs/python/mail

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

Sidebar

Related Questions

i have this link: http://localhost/login/activation.php?usermail=xxxxx@gmail.com?usercode=$P$Bs9FpyKdKVFdVXYJ6dZCfcZqzWHLlc/ but this validation return Bad request. Why? function checkBd()
Am using mail.jar and activation.jar as classpath and have programmed a automatic mail sending
I am using the following code for sending e-mail (gmail) using Java program. I
I have a full working php script for user activation that I wrote. Fully
I have following ant mail task - <target name=sendtestreport > <mail mailhost=smtp.com mailport=1025 subject=Test
I have a WCF service and use Spring.ServiceModel.Activation.ServiceHostFactory as a factory in my *.svc.
I have 2 Message driven beans. 2 Activation Specs for these beans. I have
I have a WCF service: <%@ ServiceHost Language=C# Debug=true Service=IWW.MIGTurbo2.WCF.Security.SecurityBroker Factory=System.ServiceModel.Activation.WebScriptServiceHostFactory %> This works
Have a look at this picture alt text http://www.abbeylegal.com/downloads/2009-04-01/web%20part%20top%20line.jpg Does anyone know what css
I have written java code for send mail which is giving exception : when

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.