Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Problem with sending HTML email from Python

Hello,


This is the code I am using: https://pastebin.com/GJQTm7eA


I want to put the subject in the text but as every email has different subject I get them from a spredsheet. I cannot get the subject from the spreadsheet in the HTML version tho.


Anybody has any idea how to do it? In the pastebin is the latest version I came with, but it is buggy.


When it sends an email there is blank line between html and the subject and between the subject and html2
What is the solution you found?

Please don't destroy site content via the edit feature. If people continue to do that, further restrictions could be a result.
(Mar 19, 2020 12:04 PM)webdev77 Wrote:  What is the solution you found?

Please don't destroy site content via the edit feature. If people continue to do that, further restrictions could be a result.

My bad.

Old code:
Code
html = """\
    <html>
      <head></head>
      <body>
        <p>Hello,<br>
           I am aaaa and I represent aaaaa<br>
           We are a aaaa site for aaaaaaa.<br>
           We would like to collaborate</p>
      </body>
    </html>
    """

    html2 = """\
    <html>
      <head></head>
      <body>
        <p>. Please get back to us  
        </p>
      </body>
    </html>
    """

    html = html + all_subjects[idx] + html2

Working code:

Code
html = """Hello,<br>
           I am aaaa and I represent aaaaa<br>
           We are a aaaa site for aaaaaaa.<br>
           We would like to collaborate for """

    html2 = """<html>Please get back to us  
    </html>"""

    html = html + all_subjects[idx] + html2

The head and the body from the html were ruining it. I removed them as I don't really need them, this is a simple email. I just needed to put my signature in there.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by HackersNov 11, 2025 09:42 AM 0 206 Nov 11, 2025 09:42 AM
Last Post: Hackers
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by g-ezOct 1, 2018 07:39 AM 5 264 Oct 1, 2018 07:39 AM
Last Post: g-ez