Tickets, boarding passes and receipts are the emails where a QR code earns its place: something will scan it later, at a door or a counter. A newsletter code that just opens a link is usually worse than the link.
The snippet
<table role="presentation" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center" style="padding:16px; background:#ffffff;">
<img src="https://qrcodesforever.com/qr.png?url=example.com%2Fticket%2F123"
alt="QR code for your ticket" width="180" height="180"
style="display:block; border:0;">
<p style="margin:8px 0 0; font-size:14px;">
Can't scan it? <a href="https://example.com/ticket/123">Open your ticket</a>
</p>
</td>
</tr>
</table>
The image is a 512-pixel PNG of about 29 KB, and its code contains https://example.com/ticket/123. Shown at 180 pixels, it stays sharp on high-density phone screens. Each choice in the snippet is there for a reason:
- PNG, not SVG. Email apps differ a lot in how they handle SVG. PNG shows up nearly everywhere.
widthandheightas attributes, because some email apps ignore CSS sizes on images.display:blockandborder:0remove the stray gaps and borders some apps add around images.- A white cell behind the code. Some apps invert colors in dark mode. A QR code needs dark modules on a light background to scan, so the cell gives it one. Leave
transparent=1out of email for the same reason. - A text link, for readers whose app holds back images and for anyone reading on the phone they'd scan with.
A code per recipient
Put a merge tag inside the image URL and each person gets their own code:
https://qrcodesforever.com/qr.png?url=example.com%2Fticket%2F{{ticket_id}}
Tag syntax depends on the platform; Mailchimp uses *|MERGE|* tags and many others use {{ }}. A ticket number made of digits needs no encoding. If the merged value can contain spaces, & or #, encode it in the tool or store an encoded copy, because an unencoded & would cut the code's link short.
Every recipient's code is a separate image URL, and each one is drawn on first request and then served from cache. If you send from your own code, build the URL with a real encoder; the Node.js and Python guides show how.
Other kinds of code in email
An event invite can carry a calendar code, so someone with a printed copy can add the event by scanning. A rental's arrival email can carry a Wi-Fi code. The embed reference has the fields for both. Brand colors work with fg and bg as long as the code stays dark on light; check a pair with the contrast checker before it goes to a list.