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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:19:43+00:00 2026-06-09T10:19:43+00:00

My current script allows me to send emails fine, but there are just some

  • 0

My current script allows me to send emails fine, but there are just some characters it doesn’t like, particularly ':' in this sample.

import smtplib, sys

mensaje = sys.argv[1]
def mailto(toaddrs, msg):
    fromaddr = 'myemailblabla'

    username = 'thisismyemail'
    password = '122344'

    server = smtplib.SMTP('smtp.gmail.com:587')
    server.starttls()
    server.login(username, password)
    server.sendmail(fromaddr, toaddrs, msg)
    server.quit()

mailto('test@gmail.com', mensaje)

If I write a sample message such as, let’s say "Hi there\n how are you?" it works fine, but let’s say I try to send a url http://www.neopets.com, the email is sent blank. I believe the ':' causes this issue, so I tried escaping it, but nothing.

  • 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-09T10:19:44+00:00Added an answer on June 9, 2026 at 10:19 am

    The problem is that smtplib is not putting a blank line between the message header and the message body as shown by in the “Show Original” form of my test:

    Return-Path: <me@gmail.com>
    Received: **REDACTED**
            Fri, 03 Aug 2012 06:56:20 -0700 (PDT)
    Message-ID: <501bd884.850c320b@mx.google.com>
    Date: Fri, 03 Aug 2012 06:56:20 -0700 (PDT)
    From: me@gmail.com
    http: //www.example.com
    

    Although this is a legal mail header, Mail Transfer Agents and Mail User Agents should ignore apparent header fields they don’t understand. And because the RFC822 header continues until the first blank line and http: looks like a header line, it is parsed as if it were a header. If given a newline:

    mensaje = '\nhttp://www.example.com'
    

    Then it works as expected. Although email technically only needs the “envelope” as provided by smtplib the contents of the mail should be more complete if you expect your recipients (and their mailers) to treat the message nicely, you should probably use the email module to generate the body.

    added

    Based on the doctest in smtplib.py it looks as if this is an intentional feature allowing the caller of sendmail() to append to the header:

         >>> msg = '''\\
         ... From: Me@my.org
         ... Subject: testin'...
         ...
         ... This is a test '''
         >>> s.sendmail("me@my.org", tolist, msg)
    

    Where the From: and Subject: lines are part of the “nice” headers I mentioned above.

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

Sidebar

Related Questions

I would like to run a script indefinitely. It look likes my current script,
Can anyone help me with reversing this PHP page navigation? Current script setting shows
What is current directory of shell script? Is this current directory from which I
I wrote a .vbs script that emails the admin with the current log file
Is there a selector or function in JQuery that allows to select the current
For my current project, I am creating a php script that allows our Instructors
I copied this script from internet but idon't know how to use it. i
Is there a tool that allows me to create a sql populate script for
i have written this python program. whenever i run the script using parameters like
I already wrote a PHP script that allows users to upload images but I

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.