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

  • SEARCH
  • Home
  • 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 8152359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:41:25+00:00 2026-06-06T15:41:25+00:00

I recently found a code to send emails using python. It was only for

  • 0

I recently found a code to send emails using python. It was only for a single user so I modified it to take emails from a txt file which stores the email on every line and then send them mails. However what I found is that the mails end up in the spam folder(in case of Gmail) or the Junk folder (in case of hotmail or live). Is it possible to change the code so that the message lands in the inbox instead of being filtered as spam? Did I get something wrong?

import smtplib,sys

server = 'smtp.gmail.com'
port = 587

sender = 'my-username@gmail.com'
subject = 'Gmail SMTP Test'
body = 'blah blah blah'

"Sends an e-mail to the specified recipient."



session = smtplib.SMTP(server, port)

session.ehlo()
session.starttls()
session.ehlo
session.login(sender, 'my-password!')

f = open('emails.txt')
for line in f:
  recipient = line
  print recipient
  headers = ["From: " + sender,
       "Subject: " + subject,
       "To: " + recipient]
  headers = "\r\n".join(headers)
  session.sendmail(sender, recipient, headers + "\r\n\r\n" + body)

f.close()
session.quit()
  • 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-06T15:41:27+00:00Added an answer on June 6, 2026 at 3:41 pm

    That’s a very difficult question, because the spam classification is not done by you. (Obviously! If anyone could make their messages “not spam” then of course the spammers would do that too.)

    There are various things you should do if you are seriously thinking about sending large-scale email, involving authenticating servers etc. Unless you are an expert, you should engage the services of a mailing company to do them.

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

Sidebar

Related Questions

I recently found the code below in one of my directories, in a file
I've been using eval in my code and I recently found out that there
I recently found myself using the same pattern over and over in my code.
I recently found myself writing a piece of code that executed a Core Data
I just recently found myself writing this line of code, which i did not
A coworker recently showed me some code that he found online. It appears to
recently found an article in http://hashtwo.com/blog/integrating-a-file-browser-into-ckeditor-cakephp to integrate a file browser into ckeditor (file
This question is based off some really odd code I recently found in a
I have used the following code several times before, and have recently found it
I recently found a problem, which can add to technology of calender A user

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.