How to send Email sending without html format - html

I send email in rails using mailer.It send successfully.But the way it send is not proper.It is sending in html tags like that
Sent mail to xxx (3.6ms)
Date: Mon, 09 Nov 2015 14:53:15 +0500
From: from#example.com
To: xxx
Message-ID: <56406d0b15b8e_6f03f8d3408607861097#des-0071.mail>
Subject: Password Reset
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<html>
<body>
<p>Hello </p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p>Change my password</p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
</body>
</html>
File is password_reset.html.erb

In rails console, you can see the html tag actually. But in the real email you could not see those HTML tags. Try to run not using console but run actually how do you want it to call. Use mailcatchergem to see real results of the email.
In short, you can install and run like this:
gem install mailcatcher
run mailcatcher to your bash.
Go to browser: http://localhost:1080/
Then you can see like this image.

The email client will render those tags once the email is received by the user and you will not see any of them. An email template is treated very much like a View in Rails. if you take everything between <html> and </html> and save it in a file and open it in a browser, that's what the email will look like for the user.
Also you want to send an absolute path in your email link, that is a relative link you have right now and if the user clicks it outside your website (from an email client) it will not work.

Related

How to prevent Thunderbird from rewriting URLs to hyperlinks when composing html emails?

I'm using Thunderbird 52.5.2 on Windows 7.
When I compose the html emails and send, Thunderbird will convert the email addresses and the http:// urls I wrote to clickable hyperlinks when sending the email out. I don't want Thunderbird to do that for me and I would do that manually when I need by insert->links.
How to prevent Thunderbird from automatically rewriting URLs to hyperlinks when I compose and send the html emails ?
For example, I would like to compose a html email like this:
Email content I composed (I'm not able to embed img now, please click to view)
Thunderbird will rewrite the email address and http url as below (source code view)
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=en-US">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<b>H</b><i>ELLO</i><br>
This is an email address <a class="moz-txt-link-abbreviated" href="mailto:dummy#example.com">dummy#example.com</a><br>
This is a http url <a class="moz-txt-link-freetext" href="http://www.example.com/dummy.html">http://www.example.com/dummy.html</a><br>
<br>
</body>
</html>
But I want Thunderbird keep what I wrote as below (source code view):
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=en-US">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<b>H</b><i>ELLO</i><br>
This is an email address dummy#example.com<br>
This is a http url http://www.example.com/dummy.html<br>
<br>
</body>
</html>
Inspired from previous answer. I found another trick that DO make Thunderbird render my email correctly which has no clickable links.
When I compose a html email and edit to an email address, I have to manually use insert-->html it as below:
dummy<span>#</span>example.com
and below is for html urls:
http<span>:</span>//www.example.com/dummy.html
Then I got a perfect result.
I have wanted the same feature you requested, but the closest I have been able to get it is using the following work-around.
1) After I create the email, instead of immediately sending, I use the "send later" feature which places the email into the Outbox folder. See https://addons.thunderbird.net/en-US/thunderbird/addon/send-later-button/?src=search?src=search
At this point the email if formatted with the HTML codes for anchor text and hyperlinks as the OP indicated.
2) Then I use the "Edit Full Source" feature of "Header Tools Lite" Add-On to remove the unwanted HTML code. See https://addons.thunderbird.net/en-US/thunderbird/addon/header-tools-lite/?src=search?src=search
BTW, the other work-arounds provided by others above, leave HTML code in the email. Though the hyperlink within the email may not function, the anchor text still remains formatted as a link. This is because of the lingering HTML codes remaining in the email.
One trick I found is to enclose the url in <a>..</a> tags.
This may seem silly, but it will prevent linkification from taking place, and without a href attribute, there will be no other interaction.
This is an email address <a>dummy#example.com</a><br>

HTML mail not being properly displayed in Gmail, Outlook, etc

I am sending mails from the command prompt as-
mail -s "$(echo -e "This is the subject\nContent-Type: text/html")" <my-email-id> < ~/Downloads/report-scripts/mail.html
The file mail.html is a perfectly written HTML file, which when viewed in browser, renders perfectly. However when sent through mail (say to Gmail), some layout issues creep in. See the following images -
Browser Image -
Mail Image -
Note the extra </td> element.
I understand that email providers don't render HTML mail as it, and add their own styles to it. Is there any way to resolve this issue?
Okay,
I have resolved the issue and I have an indication of what might be the problem, but I am not sure about it.
Using mutt instead of mail solved the issue. So the problem is linked to the mailing utility and not the HTML itself.
RCA-
I checked the original mail content. You can do that in Gmail by following the image
For mutt, the content was as follows -
From: <Some email id>
To: <Some email id>
Subject: <Some subject>
Message-ID: <20160218081616.GA6060#<machine description>>
MIME-Version: 1.0
Content-Type: text/html; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
User-Agent: Mutt/1.5.21 (2010-09-15)
and for mail, it was as follows -
Subject: <Some subject>
Content-Type: text/html
To: <some email id>
X-Mailer: mail (GNU Mailutils 2.99.97)
Message-Id: <20160215054331.4C3EA25E27#<machine-description>
Date: Mon, 15 Feb 2016 11:13:31 +0530 (IST)
From: <some email id>
I think it has something to do with the headers sent with the mail.

How to add URL link in email body message in riemann

I am trying to add a html URL tag in my email body. I have used like below,
:body (fn [events] "Hello Team.\n Welcome \n Link to my website \n * This is an automated e-mail and any responses to this e-mail will not be monitored \n Thank You!")
My html tag was not recognized . I am getting the output like below,
Hello Team,
Welcome
Link to Kibana DashBoard
* This is an automated e-mail and any responses to this e-mail will not be monitored Thank You!.
Do I need to use any filter to create a link in clojure.
Thanks in advance.
This is because by default you are sending a plain text email.
Riemann defers to Postal for sending emails, see here for how to send HTML emails.

When sending an email with meteorjs, the base64 inline image is not displayed correctly

Current situation:
(Client side) The template:
<template name="feedback">
<h1>The Image</h1>
<img src="{{image}}" alt=""/>
</template>
(Client side) Calling the mail function:
var dataContext={
image: canvas.toDataURL('image/png')
};
var html=Blaze.toHTMLWithData(Template.feedback, dataContext);
Meteor.call('feedback', html);
(Server side):
Email.send({
to: 'xxx',
from: 'xxx',
subject: 'xxx',
html: html
});
Expected result: A nice email with an embedded image.
Actual result: I get a mail partially html, partially 'raw' text. I have no clue to why.
This is a part of what I see in the raw email:
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<h1>The Image</h1>
=20=20=20=20<img =
src=3D"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAALKCAYAAADTWUxrAA
Any ideas?
Gmail, as well as many other clients, do not allow you to use base64 as a source in an img tag. There are ways around this though:
First and easiest might be to just keep the image on your server and put a url into the image source tag. This has the added benefit of being able to handle some tracking (some additional development required).
Second would be to use a third party mail system and send them the image and the HTML and set it up this way. This might be good for a number of reasons but it doesn't really answer your question.
Finally you can do this in an email template like you have by adding a multipart multitype boundary solution very similar to this answer:
base64 encoded images in email signatures

Submit to HttpHandler results in RequestType GET instead of POST

My ActionHandler.ashx file should be POSTed yet upon entry to ProcessRequest the context.Request.RequestType is always "GET".
Background:
This HttpHandler currently works OK (i.e. clicking a link in an email causes my ActionHandler.ashx to be entered and the querystring is processed correctly). For example:
https://mdwdata/CorporateBrain/ActionHandler.ashx?Action=MarkComplete&ID=1024~nzmewoojgnn&CUID=13
is the URL for the link shown as Mark-Complete in the image just below:
But now I am trying to improve it by following this advice in a previous SO thread :
"In the body of the email, instead of sending a link, include an HTML form that contains a button which performs a postback to your server."
Problem Summary: When I click the Submit button, my handler is entered with verb GET not POST (hence, I have no access to the hidden form data in the Request.Form collection.
Here is a snippet (image) of the email body
If I can get the Submit to post the hidden form variables to my handler, then of course I would remove the links. In the debugger, I verified the form data and it looks good me:
I added this line to my web.config file:
<add path="ActionHandler.ashx" verb="GET,POST" type="System.Web.UI.SimpleHandlerFactory" validate="true" />
Also, my email client is Thunderbird.
What would cause the request to be GET instead of POST?
The short answer to this problem is that Thunderbird does not POST to the URL in the Action attribute of the HTML form tag. Even the newest version of Thunderbird (version 31.2.0) "ignores" the POST and requests the URL via GET.
The construction of the HTML form is properly done and other email clients I have tested work fine:
Microsoft Office 365 Outlook Web App
Google GMail
So, I guess I am doing it "right" but some email clients apparently don't support this (even my favorite which is Thunderbird).