E
E
Eduard Talovikov2019-11-06 17:55:45
PHP
Eduard Talovikov, 2019-11-06 17:55:45

How to do it (all info in the description)?

addr_to = "[email protected]"        
            addr_from   = "[email protected]"                   
            password  = "example"
            msg = MIMEMultipart()                               
            msg['From']    = addr_from                          
            msg['To']      = addr_to                            
            msg['Subject'] = asa["description"]
            #body ="<p>%s</p>" %(inc["key"])+" "+"<p>%s</p>" %(asa["description"])+" "+"<p>%s</p>" %(inc['name'])
            #body =inc["key"]+"---"+  asa["description"]+"---"+  inc['name']
            msg.attach(MIMEText(body, 'plain'))
            html = """\
            <html>
              <head></head>
              <body>
                  <div>
                      <p></p><!--- Как в эти абзацы вставить постоянно обновляющиеся переменные 
                       inc['name'],asa["desc"],inc["key"]  --->
                      <p></p>       
                      <p></p>
                  </div>
              </body>
            </html>
            """
            msg.attach(MIMEText(html, 'html', 'utf-8'))
            server = smtplib.SMTP('smtp.gmail.com', 587)        
            server.starttls()                                   
            server.login(addr_from, password)               
            server.send_message(msg)                            
            server.quit()

The purpose of the program is simply to send data by mail through a card with html code, how to embed inc, asa variables in paragraphs. And how to create a card with defined dimensions, color, background, variables, so that the information supplied via mail can be considered as a picture with dynamic variables, and not text. Upd: What a comment, I just tested it

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vlad Azan, 2018-10-04
@Azan

When outputting, I need to clean from html tags
strip_tags($TEXT);
Or in css to the block write
color: black !important;
(In general, you need to be more specific in describing the essence of the problem)

Y
Yura Khlyan, 2019-11-06
@MAGistr_MTM

Read about jang templates
In general, you need to:
1. Create a template
2. Pass a context
3. Render a
PS template. variables are passed to the template viaText here. {{ var }} from context.

M
Maxim, 2019-11-06
@Tomio

String formatting will help you, namely, the format method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question