This is an HTML email with formatting.
- Feature 1
- Feature 2
- Feature 3
import { tap, expect } from '@git.zone/tstest/tapbundle'; import { startTestServer, stopTestServer, type ITestServer } from '../../helpers/server.loader.js'; import { createSmtpClient } from '../../../ts/mail/delivery/smtpclient/index.js'; import { Email } from '../../../ts/mail/core/classes.email.js'; let testServer: ITestServer; tap.test('setup test SMTP server', async () => { testServer = await startTestServer({ port: 2567, tlsEnabled: false, authRequired: false }); expect(testServer).toBeTruthy(); expect(testServer.port).toEqual(2567); }); tap.test('CEP-07: Basic HTML email', async () => { const smtpClient = await createSmtpClient({ host: testServer.hostname, port: testServer.port, secure: false, connectionTimeout: 5000 }); // Create HTML email const email = new Email({ from: 'sender@example.com', to: 'recipient@example.com', subject: 'HTML Email Test', html: `
This is an HTML email with formatting.
Here's an inline image:
And here's another one:
Product 1
Product 2
Product 3
© 2024 Example Corp
`, text: 'Monthly Newsletter - View in HTML for best experience', attachments: [ { filename: 'header-bg.jpg', content: Buffer.from('fake-image-data'), contentType: 'image/jpeg', cid: 'header-bg' }, { filename: 'logo.png', content: Buffer.from('fake-logo-data'), contentType: 'image/png', cid: 'logo' }, { filename: 'product1.jpg', content: Buffer.from('fake-product1-data'), contentType: 'image/jpeg', cid: 'product1' }, { filename: 'product2.jpg', content: Buffer.from('fake-product2-data'), contentType: 'image/jpeg', cid: 'product2' }, { filename: 'product3.jpg', content: Buffer.from('fake-product3-data'), contentType: 'image/jpeg', cid: 'product3' }, { filename: 'divider.gif', content: Buffer.from('fake-divider-data'), contentType: 'image/gif', cid: 'footer-divider' } ] }); const result = await smtpClient.sendMail(email); expect(result.success).toBeTruthy(); console.log('Complex HTML with multiple inline resources sent successfully'); }); tap.test('CEP-07: HTML with external and inline images mixed', async () => { const smtpClient = await createSmtpClient({ host: testServer.hostname, port: testServer.port, secure: false, connectionTimeout: 5000 }); // Mix of inline and external images const email = new Email({ from: 'sender@example.com', to: 'recipient@example.com', subject: 'Mixed Image Sources', html: `Left column content
Right column content
This text is hidden on mobile devices
This is safe text content.
Get 20% off with code: SPRING20
© 2024 Example Corp | Unsubscribe