Where to set Content Language for email? - email

Sending HTML emails in different languages, such as English and French.
Is it a best practice to set the Content-Language header in the
HTML lang tag: <html lang="fr">
Email header Content-Language
Both

This works:
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" />

TL;DR: You can set the Content-Language in the header. If your mail is a multipart message with alternatives in other languages (e.g. when you send a mail with translations), you can set a different one in the headers for those alternatives.
There are two RFC's of interest here RFC 3282 about Content-Language headers and RFC 2045 about message bodies.
From 2045 section 9
Additional MIME Header Fields
Future documents may elect to define additional MIME header fields
for various purposes. Any new header field that further describes
the content of a message should begin with the string "Content-" to
allow such fields which appear in a message header to be
distinguished from ordinary RFC 822 message header fields.
MIME-extension-field := <Any RFC 822 header field which
begins with the string
"Content-">
And from 2045 section 3 you can conclude that an extra Content-Language header can be set on every body part for multipart messages.
If you like seeing examples, the Mozilla comm-central repo (Thunderbird and other MUA's) has some nice test data with examples: https://hg.mozilla.org/comm-central/file/tip/mailnews/test/data
If you are reading this in the future, you may be able to convey the language in the character set RFC 2231.

Related

Gmail strips body out of mailto links

I've been seeing this issue on a website I support, and have confirmed it is the case elsewhere as well.
When using a mailto link for sharing a URL, I see that some clients are fine with displaying the body field from the mailto link in the email, while Gmail strips it out.
I've seen a few related questions here but none suggesting a fix or workaround.
I've also seen some mention that the body field is non-standard, but it seems that it is required that it be honored in the spec.
https://www.rfc-editor.org/rfc/rfc6068#page-7
The creator of a 'mailto' URI cannot expect the resolver of a URI
to understand more than the "subject" header field and "body".
Clients that resolve 'mailto' URIs into mail messages MUST be able
to correctly create [RFC5322]-compliant mail messages using the
"subject" header field and "body".
Is Gmail therefore non-compliant?
To demonstrate the behavior I am seeing, with Gmail as your default email client, paste the following into your browser url bar: mailto:?subject=qux&body=xyzzy
If your experience is consistent with mine, you will not have a body in the Gmail message, and will only have a subject. Upon inspection, you may see that the url bar for the Gmail webapp reads something like the following: https://mail.google.com/mail/u/0/?view=cm&fs=1&tf=1&source=mailto&su=qux, with su representing the subject field from the original mailto url, and sure enough, no field representing body.
Now, changing your default email client (I tried with the Mail macOS application) you will see both subject and body populated.
Has anyone had any luck getting the specified behavior working in Gmail?
Gmail omits all query string parameters after the first one separated by an unencoded ampersand. So if you put ?subject first, you get only subject; if you put ?body first, you get only the body. I changed this:
<a href="mailto:?body=https%3A%2F%2Fexample.com&subject=Testing">
to this, with the ampersand encoded as %26:
<a href="mailto:?body=https%3A%2F%2Fexample.com%26subject=Testing">
...and it works in Gmail, but Mail.app gets the entire query string as the email body. But as I said, Gmail omits everything after the first unencoded ampersand. So I repeated both body and subject with unencoded ampersands, and this seems to work everywhere:
<a href="mailto:?body=https%3A%2F%2Fexample.com%26subject=Testing&body=https%3A%2F%2Fexample.com&subject=Testing">
Put more clearly, in JavaScript, if bodyText is your URL encoded body text, and subjectText is your URL-encoded subject line, then the format you need for full compatibility with Gmail and others is this:
const emailUrl = `mailto:?body=${bodyText}%26subject=${subjectText}&body=${bodyText}&subject=${subjectText}`;
Here also is a Twig version. This Twig file gets unencoded url and title variables for the body and subject respectively:
{% set body %}body={{ url|escape('url') }}{% endset %}
{% set subject %}subject={{ title|escape('url') }}{% endset %}
{% set query_string %}?{{ body }}%26{{ subject }}&{{ body }}&{{ subject }}{% endset %}
<a class="share__button" href="mailto:{{ query_string }}"><span>{{ 'Email this article'|t }}</span></a>

How to set a custom header using phpmailer

I am using phpmailer for sending emails, but I want to make a custom header for my company, by adding a textarea field that contain any custom header for example using a header like this one:
exemple of header
or any other header types..
How can I do this , thanks in advance.
You will need to do some discovery and modification of the default headers set by PHPmailer for this to be achieved.
You will need to use different functions to set/edit headers depending on the type of header you want to set/edit. Here are a few examples:
From:
$mail->setFrom('from#example.com', 'Mailer');
Subject:
$mail->Subject = 'Here is the subject';
Custom:
$mail->addCustomHeader('X-custom-header', 'custom-value');
In short, It is quite an effort to do this when the headers are free-typed in a text box. It is however doable with detection and validation on your side.

HTML4.01 Strict ARIA Doctype for Validation via W3C Validator

Is there any <!doctype> for "HTML 4.01 Strict Markup + ARIA"?
Also am currently having HTML 4.01 Strict <!DOCTYPE>, I obviously get an error while validating my page with the W3C Validator.
Is there any solution to this problem?
Also when I use the Accessibilty Toolbar, I get the following error pointing to the line after the closing HTML tag:
Line 256, Column 1: character data is not allowed here
Content-Disposition: form-data; name="charset"
You have used character data somewhere it is not permitted to appear.
Mistakes that can cause this error include:
putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>), or
forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or
using XHTML-style self-closing tags (such as <meta ... />) in HTML 4.01 or earlier. To fix, remove the extra slash ('/') character. For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML.
There is no published DTD for HTML 4.01 + ARIA. It would be possible to write one, if only there were a stable, exact document that specifies the allowed ARIA attributes and the HTML 4.01 elements on which they may be used. Using WAI-ARIA in HTML is still a WD only, and calls itself “a practical guide”. And I’m not sure how it should be interpreted. I guess the simplest, and possibly the only realistic, approach would be to write a DTD that allows all ARIA attributes on all elements, with the same set of values for all elements, even thoughh this would violate many of the recommendations.
The other question seems to be unrelated, and should probably be asked as a separate question. And you should probably explain what accessibility toolbar you are referring to and what your HTML document contains.

confused about xhtml5: no more `<?xml?>` and now mandatory `meta`?

I've been a longtime user of XHTML 1.0 Strict, and I'm now trying to switch to XHTML5 in my new projects.
I'm confused that <?xml version='1.0' encoding='utf-8'?> is no longer considered valid, for HTML5, by http://validator.w3.org/. Why is that? Isn't that what all xml documents are supposed to start with?
And when I remove the standard <?xml…, my document still doesn't validate: now it's missing the encoding. I don't like those meta tags, but are they now effectively mandatory, to specify the encoding, in order to be valid (X)HTML5?
An XML declaration is valid and validates in XHTML serialization of HTML5. The following rather minimal document validates:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title></title></head>
<body></body>
</html>
However, this only applies to XHTML serialization (XHTML syntax) of HTML5. In HTML serialization, it is not allowed. If you write the above document in a file and store it in a server that will send it with Content-Type: text/html (which normally happens if the filename ends with “.html”), then you get an error message:
Saw <?. Probable cause: Attempt to use an XML processing instruction in HTML.
(XML processing instructions are not supported in HTML.)
Here “HTML” means HTML serialization only.
Browsers do not care about an XML declaration in either syntax. In HTML syntax, it is just ignored, as a recoverable syntax error. In XHTML syntax, it does not matter, except for the encoding part.
Although XML 1.0 specification recommends (but does not require) an XML declaration, it would in practice matter (apart from the significance of encoding) only to software that is capable of processing different versions of XML. Browsers aren’t. And in addition to XML 1.0, there’s just XML 1.1, which is not used much. Besides, HTML5 is defined so that the XML version used in XHTML syntax is XML 1.0.
The encoding part may matter, but utf-8 is the default anyway for XML. If you use another encoding for some reason, then an XML declaration may be useful to prevent any conflicts. HTML5 CR says this in it discussion of encodings: “In XHTML, the XML declaration should be used for inline character encoding information, if necessary.” A meta tag cannot really help in XHTML when served with an XML content type, since the encoding has already been decided (by defaulting to UTF-8 or otherwise) when the tag is seen.
For HTML syntax, the <meta charset=...> tag may be used, but it is not needed for validity, and the encoding can be specified in HTTP headers (which override any meta tags). Using a meta tag may however be helpful, since a page might be saved locally, and then there won’t be any HTTP headers available when it is opened.

Set request parameter in Orbeon

I am very new to Orbeon and XForms.
I have created a form with input field "BaseId"
<xf:input id="control-3-control" bind="control-3-bind">
<xf:label ref="$form-resources/control-3/label"/>
<xf:hint ref="$form-resources/control-3/hint"/>
<xf:help ref="$form-resources/control-3/help"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</xf:input>
and i want when i summit this form, in crud.xpl
method PUT i cant get value of BaseId through
<sql:param type="xs:string" select="/request/baseid"/>
Help me,please
Sorry for my bad English
The value of controls are passed to the persistence layer REST API in an XML document, as the body of the HTTP request. So in crud.xpl (say the one for eXist), this will be a document under /request/body. The exact path depends on your section and control name. For instance, if the section is named address and the field city, the value will be under /request/body/form/address/city.