How do you send HTML content with SendGrid? - ruby-on-rails

Trying to send HTML content in a SendGrid email header. I am getting drop email. The error is "REASON: Invalid SMTPAPI header"
This is my email template code
<%body%>
--|ALERT_MESSAGE|--
Here is the content I want to send (ROR string)
content = "<p>The system following info. [#{message}] <a href='#{url}'>#{url}</a></p>"
Here is my header code (self in this case is the header)
self.add_category("System Email")
self.add_filter('templates', 'enable', 1)
self.add_filter('templates', 'template_id', 'sdfs-f8fd6029')
self.add_substitution('--|MESSAGE|--', [content])
self.set_tos(SENDGRID_EMAILS)

Even if you are using a template, you need to specify some kind of body in the actual message, so that means you need to pass the html parameter i your request. This is an artifact due to transactional templates being added to the existing endpoint. A new mail sending endpoint is in the works that will not require text or html to be defined if a template is used.

Related

Hyperlink URL changed by mailinator, how to fix?

Ruby on rails server.
We are sending an email.
The content has a hyperlink, containing a URL which has a token in its query params.
The content also has the same URL in plain text.
Hyperlink
%p= link_to "Review", "#{#link}", target: "_blank"
Plain text
%p{ style: "word-wrap: break-word;" } #{#link}
When the destination address is #mailinator.com, the hyperlink URL will be altered and the security token from the URL params will not work anymore on the server.
This is the correct token from the plain text URL:
token=HM%2FTEkoKiTaBp0Ue%2BwPqjQ7Oxj4%2F1rWVuzgrxlUv2JEe6uGgdyuO41ENztyW%0A%2FpXewq1qY8MC
And this is the token from the URL modified by mailinator (the one you get after accessing the hyperlink):
token=HM/TEkoKiTaBp0Ue+wPqjQ7Oxj4/1rWVuzgrxlUv2JEe6uGgdyuO41ENztyW%0A/pXewq1qY8MCVa7fcmuu
QUESTIONS:
Is there anything on my side that I can do to fix this?
I checked and gmail does not alter the URL from the hyperlink.
OPINIONS:
I think this is a bug on the mailinator side.
From what I see, the mailinator guys are URL Decoding my token:
From the original:
HM%2FTE
They output:
HM/TE
Which is exactly the URL Decoding of the original value.

how to prevent message creation api to resend complete message

I use graph api to create a message with attachment(s).
All runs fine but the server send back the complete message in response, including the attachments.
Is there a way to only get the message id in the response ?
I try with :
string webApiUrl = $"{_apiUrl}v1.0/users/{senderId}/messages?$select=id"
but I still get the whole message with 98ko of attachment.
You can do it using the prefer:return=minimal header in the request which will mean you will just get a 204 response. However the id of the item that was created will be returned in the location header (the response should really have the OData-EntityId if they are following the oData spec to the letter, also I'm not sure why it return the Outlook v2 location rather then the graph but the message Id is the same between them)

HTML file path is coming in the Email body instead of HTML file content in Jenkins using Email-ext

I am giving the below option in Jenkins,
Post-build Actions:
Content Type: HTML (text/html)
Default Subject: $DEFAULT_SUBJECT
Default Content: ${FILE,path="c:/aaa/bbb/ccc/report.html”}
But if I check the email received via jenkins, its showing the file path in the email body as '${FILE,path="c:/aaa/bbb/ccc/report.html”}' instead of actually displaying the content inside the HTML file

Create Custom HTTP Header

I want to deliver a soap message by HTTPS/Post by specifying Content-Type application/HTTPstream and the following custom HTTP-headers
datatype = 'XML' userid= password
I tried with CALL CopyMessageHeaders();
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'application/HTTPstream';
and other part same as this but I am not getting Headers in my output message

Consuming Yellow Pages.com using FSharp Type Providers

I signed up for the yellow pages.com API program found here: https://publisher.yp.com/home.
I went to make a call like this and I am getting back JSON in the browser:
http://pubapi.atti.com/search-api/search/devapi/search?term=Jumbo+China+5&searchloc=6108+Falls+Of+Neuse+Rd+27609&format=json&key=ZZZZZZZZ
When I take the json results and put it into Json2CSharp, it renders fine. When I try and load it into a type provider:
type RestaurantListingJson = JsonProvider< #"http://pubapi.atti.com/search-api/search/devapi/search?term=Jumbo+China+5&searchloc=6108+Falls+Of+Neuse+Rd+27609&format=json&key=ZZZZZZZ">
I get a 400
Looking at fiddler, I see
"User agent is a required field"
Has anyone run into this before? How do I add a user agent to a type provider?
Thanks in advance
I have not created an account, so I could not try this - but if the error message says "user agent is a required field", then I guess that the service requires setting the User-Agent header of the HTTP request.
This is not supported in static parameters of the JsonProvider, so the best way to get this to work would be to download the sample JSON, save it to a local file (say yp.json) and then use that to create the type provider:
type Yp = JsonProvider<"yp.json">
To actually download some data (when you want to make a request), you can use Http.RequestString which takes headers - there you can specify any required headers including User-Agent:
let response =
Http.RequestString("http://httpbin.org/user-agent", headers=["user-agent", "test"])
Then you can load the data using Yp.Parse(response) (rather than using the Load method directly to request a URL which would not let you specify the header).
The latest version of F# Data now always sends user agent and accept headers, so this should now work directly:
type RestaurantListingJson = JsonProvider<"http://pubapi.atti.com/search-api/search/devapi/search?term=Jumbo+China+5&searchloc=6108+Falls+Of+Neuse+Rd+27609&format=json&key=ZZZZZZZ">

Resources