简体   繁体   中英

Converting Mandrill Plain-Text Emails to HTML with Template

I have been trying for weeks to convert plain-text emails and insert the converted HTML into a template using Mandrill. I can convert the plain-text emails to HTML using the Rules Engine. I can also insert HTML into a template using the Rules Engine. However, I cannot seem to do both.

I am using this template:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="viewport" content="width=device-width"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Andrew College</title>
</head>

<body style="background: #F4F4F4;">
    <div style="max-width:600px; margin: 0 auto; padding-top:20px;">
        <a href="http://solutionguard.com" target="_blank"><img src="https://www.andrewcollege.edu/sites/default/files/attachments/aclogo.png" style="padding: 10px 0px; max-width: 50%; height: auto;" alt="Andrew College"/></a>
    </div>

    <div style="max-width:600px; margin-left: auto; margin-right: auto; background:#ffffff; padding: 10px 10px 10px 10px; border: 1px solid #cfcfcf;">
        <span mc:edit="main" style="text-align:left; font-family:sans-serif; font-size: 16px; line-height: 150%;">Some sample text.</span>
    </div>

    <p style="text-align:center; font-family: sans-serif; font-size:13px; line-height:150%">&copy; <a href="https://andrewcollege.edu" target="_blank">Andrew College</a>
    </p>
</body>
</html>

Rules Engine setup:

  • If sender's email matches xxx@xxx.com, then set HTML Generation from Text ON and set template to TestTemplate using template block main .

However, the final email only shows the blank template. Using Gmail's Show Original Content function produces these results:

Content-Type: multipart/alternative; boundary="_av-zlN5SA0dJJ8qF-AJlRIGAg"
--_av-zlN5SA0dJJ8qF-AJlRIGAg
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

This is a test of the HTML template.

Thanks,
Bob User

--_av-zlN5SA0dJJ8qF-AJlRIGAg
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="viewport" content="width=device-width">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Solution Guard, LLC</title>
</head>

<body style="background: #F4F4F4;">
    <div style="max-width:600px; margin: 0 auto; padding-top:20px;">
        <a     href="http://t.andrewcollege.edu/track/click/30210239/solutionguard.com?p=eyJzIjoiQjgxaUxaYXZvekdyYTVDTmZXdXd2MHNDMk1vIiwidiI6MSwicCI6IntcInVcIjozMDIxMDIzOSxcInZcIjoxLFwidXJsXCI6XCJodHRwOlxcXC9cXFwvc29sdXRpb25ndWFyZC5jb21cIixcImlkXCI6XCI3NWM2Y2RjNjg4NDA0OTllYTQ0MTU3YTIzMDBhOThhYlwiLFwidXJsX2lkc1wiOltcIjU3ODA4MzJlMzEwZWIxNmJhYzNiMjNhYzZjNGZlODYwZDU0NmY2MWNcIl19In0" target="_blank"><img src="https://www.andrewcollege.edu/sites/default/files/attachments/aclogo.png" style="padding: 10px 0px; max-width: 50%; height: auto;" alt="Solution Guard"></a>
    </div>

    <div style="max-width:600px; margin-left: auto; margin-right: auto; background:#ffffff; padding: 10px 10px 10px 10px; border: 1px solid #cfcfcf;">
        <span style="text-align:left; font-family:sans-serif; font-size: 16px; line-height: 150%;"></span>
    </div>

    <p style="text-align:center; font-family: sans-serif; font-size:13px; line-height:150%">&copy; <a href="http://t.andrewcollege.edu/track/click/30210239/andrewcollege.edu?p=eyJzIjoiZlg1N0IzS1kyQVJqTF9KLWhZSWJyMXNSZXYwIiwidiI6MSwicCI6IntcInVcIjozMDIxMDIzOSxcInZcIjoxLFwidXJsXCI6XCJodHRwczpcXFwvXFxcL2FuZHJld2NvbGxlZ2UuZWR1XCIsXCJpZFwiOlwiNzVjNmNkYzY4ODQwNDk5ZWE0NDE1N2EyMzAwYTk4YWJcIixcInVybF9pZHNcIjpbXCI0NzNkOWZiMWQ3ODUxOGZhMmFjMjE3YzU1N2ZmYjlhYmU0MDgyZjdiXCJdfSJ9" target="_blank">Andrew College</a>
    </p>
<img src="http://t.andrewcollege.edu/track/open.php?u=30210239&id=75c6cdc68840499ea44157a2300a98ab" height="1" width="1"></body>

</html>
--_av-zlN5SA0dJJ8qF-AJlRIGAg--

Is there any way to insert the plain-text section into the HTML template? I appreciate all the help.

You won't be able to do both using rules since templates applied using rules will only place currently available HTML content into the template block (in your case "main").

And the process to convert plain-text to HTML occurs after rules are applied because if the template or HTML gets changed during the rules processing, the automatically-generated HTML would no longer match what was generated and have to be run again. So you'd want to handle the conversion to HTML prior to relaying the messages to Mandrill.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM