How can I generate html and text emails from the same source? - ruby-on-rails

I'm sending html emails using premailer. By default, it will generate a simple text rendering of the email based on the non-html content. It's an okay start, but has some annoyances such as literal rendering of all breaks.
Is there a way for me to have a little more control over the text rendering of the email, either with premailer or another tool?

You may want to check out MarkerB
It lets you write your mailer template in Markdown, and it auto-makes html and text versions of your email for sending as multipart mime.

Related

use custom link inside SMS with Twillio and Rails

I am using the Twillio Ruby gem to send sms within my application. When building my message body I have been and am using the rails 'url_helpers' to build my links like so:
message += " #{Rails.application.routes.url_helpers.vendor_auction_url(#auction)}"
I have no issue there. What I am not sure of is if I can customize the text for the link similar to an html link such as:
<%= link_to 'HERE', appointment_url(#appointment) %>
I know I can't use that same erb/html syntax. Just hoping to accomplish the same effect in a different way.
Unfortunately, you cannot use html tags in sms / text messages. All you can do is insert the URL without the tag. It then depends on the receivers device whether the URL is presented to the user as link or as plain text. Also referenced here:
create hyperlink in sms in iPhone

I need Help a finding text editor that can upload and save images to file and database

I'm new to rails and could use some help choosing the right rich text editor. I would like visitors to be able to add content (text, images, and video) to the site using one  rich text editor form. Once submitted by the visitor I need to be able to sanitize content, save images/video to public folder, and save text and the path to those images/videos to the database for future retrieval. Is there a gem or combination of gems that can help me accomplish this. 
I've already looked into tinymce, ckeditor, and mercury but none seems to meet my needs. Tinymce and ckeditor and their plugins require the URL of the image which means that users would first have to upload the image and then know the path to it. That's a little to complicated for my audience. Mercury is based in html5 and is currently unstable depending on the browser. Are there any other options out there?
http://www.queness.com/post/212/10-jquery-and-non-jquery-javascript-rich-text-editors
I didn't look to deeply, but I'm assuming one of these jquery/javascript plugins is a WYSIWYG HTML editor.
Once you've got a good client side HTML editor running, the next part is parsing the HTML when sent to the rails app.
http://www.rubyinside.com/nokogiri-ruby-html-parser-and-xml-parser-1288.html
I've never used Nokogiri, but it's name is very familiar, It seems to be used a lot.
Sanitization is baked into Rails. The default sanitize will strip out ANY HTML, but you can call sanitize telling it which HTML elements NOT to block. Assuming you parse out the HTML you allow to pass through sanitize, using Nokogiri (or whatever HTNL parser you find), you'd be manually santitizing those elements as you extract values from them.
The tricky part would be eliminating the 'file select' operation on the client side as the user needs to select a local image to place in the HTML document. I don't think you can eliminate it, but hopefully HTML editor makes it as simple as possible. There not really much you can do about it, if the user will add one of HIS images to an HTML document he'll upload, he'll HAVE to select it at some point.
This is the closest I've come to something that you describe, I'm also looking for something similar so I'll keep you posted :)
http://youhack.me/2011/07/07/create-a-facebook-post-to-wall-system-using-php-and-jquery-part-2/

BlackBerry - intercept text in HTML

I would like to be able to intercept a hyperlink from an email on BlackBerry.
e.g.
dummy site
I have been able to intercept and identify text in a plain text email using PatternRepository. However, it doesn't seem to work with HTML emails - is this even possible?
I would like to avoid the solution of scanning every incoming email myself, and parsing all the text, but this might be the only option.
Thanks
This is not possible (up to and including BlackBerry 6 afaik). It is not related to the hyperlink concept - it is not possible to use PatternRepository with any type of text within HTML text.
For performance reasons, the BlackBerry designers decided not to implement pattern matching within HTML fields (browser, or email). This is very unfortunate, but it must be dealt with.
In my app, I had the freedom to define the contents of the email. In my case, I ended up including the pattern into the subject of the email - the user can click on the subject to get to my app.
In most other situations, I think the best/only way forward is to intercept each mail as it arrives and parse it looking for the text. If I have to do that in the future, I'll try to update this post with some sample code.
There are various posts on the BlackBerry forums about this issue.
Richard

How do i create a image displaying a email with rails?

In my webapp i want to display user emails. But i dont want spam boots to steal my user emails. So have do i automatic create a image displaying there email?
Best regards,
A rails beginner
Creating an image is one way to go, but remember that OCR is getting to be an extremely "cheap" operation and isn't a guarantee that a bot wouldn't analyze all the pictures on your site to see if they contain text that looks like email addresses. There's plenty of techniques to "hide" addresses in plain sight. Write them out in character entity format, intersperse empty tags, uses javascript to decode an encoded form of them and insert into the page after load, etc...

link to an email attachment

Hi I am sending email attachments (using php) and would like to point out to the people that I send the emails to that there are attachments.
I want to do this by displaying a link in the html body of the email, so all they need to do is click the link and there system will try and open/view the attachment.
Does anyone know if this is this possible?
and if so any pointers/nudges in the right direction would be appreciated.
This will not work and it's a security concern, especially since links can be disguised and attachments can be dirty.
Add a big bold title with emphasis on the attachment, most users know how to download these from their (favorite) client.

Resources