-
Sending HTML Emails from a Drupal 7 Site
It was a little more difficult than I’d hoped to track down the proper method for sending HTML emails from Drupal 7. I’m working on a problem with Webform, so Webform emails were my primary concern. I’m not going to spend any time explaining the solution. I encourage you to look into the modules if you’re interested in learning more.
- Download and enable mailsystem
- Download and enable htmlmail
- Visit /admin/config/system/mailsystem
- Choose “HTMLMailSystem” as the mail class for all applicable “modules”
- To add a module (e.g., Webform), open the “New Setting” at the bottom and choose:
- Module = Webform
- Key = leave blank
- Save settings
- Update that module to use the HTMLMailSystem
- To add a module (e.g., Webform), open the “New Setting” at the bottom and choose:
- Try it out.
-
Devel Generate Text Settings
Devel Generate, which is part of the Devel module, makes it really simple to create dummy entities in Drupal. It’ll create everything from users to taxonomy terms to nodes. It does a great job of populating most field types (including images). Sometimes it’d be nice to have more control over the output that it’s generating. In particular, text fields often get populated with too much text.
I’ve written a module to solve this dilemma.
The Devel Generate Text Settings module lets you control the length and format (sentence structure vs. title) of text and long text fields. It also lets you easily add a prefix to the title of the nodes being generated.
One problem you may have run into is for fields that need a limited amount of words or characters. Imagine you have a Father’s Name field. Most of the time you’d expect to see two words (first name and last name). Devel Generate will almost certainly generate more than two words for this field. It may even generate 40! That’s not desirable. We need the dummy content to appear as close to the real thing as possible.
Devel Generate Text Settings gives you the ability to tell Devel Generate to stay within a certain word count, or even hit an exact word count. It also allows you to set the “treat as title” value to true, which removes any punctuation from the generated text and capitalizes the first letter of each word.
Here is what the rule might look like for the field in this example:
1field_father_name, word, 1, 2, trueThe breakdown is: when generating content for the field_father_name field, generate either one or two words. Exclude punctuation and capitalize the first letter of each word.
This is just a sandbox project for now, and it only works with nodes.
Here’s a screenshot of the admin at the time of writing:
-
Grabbing Screenshots for a List of URLs
UPDATE: There’s a better tool for this job. View my new post about Pageres.
webkit2png is a great tool for taking automatic screenshots of websites. Here’s the project’s description: “With tall or wide pages that would normally require scrolling, it takes screenshots of the whole webpage, not just the area that would be visible in a browser window.”
Here’s one way to use this tool to grab an entire list of URLs. First, make a file containing URLs, one per line. Next, simply run this (set filename, output directory, and options as needed):
1cat my_pages.txt | xargs webkit2png --delay=1 -F -D ~/my_pages_images/The “-F” argument will grab only a fullsize screenshot. There are many options to control sizing, filenames, scaling, and more. Run webkit2png --help for available options.