Skip to content

Commit f088970

Browse files
author
elbuo8
committed
Proxy server and CID
1 parent e4536c0 commit f088970

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,26 @@ email.addAttachment("image.png", new File("./image.png"));
151151
email.addAttachment("text.txt", new InputStream(new File("./file.txt")));
152152
```
153153

154+
### Content IDs
155+
156+
```java
157+
// First, add an attachment
158+
email.addAttachment("image.png", new File("./image.png"));
159+
// Map the name of the attachment to an ID
160+
email.addContentId("image.png", "ID_IN_HTML")
161+
// Map the ID in the HTML
162+
email.setHtml("<html><body>TEXT BEFORE IMAGE<img src=\"cid:ID_IN_HTML\"></img>AFTER IMAGE</body></html>")
163+
```
164+
165+
### Proxy Server Setup
166+
167+
```java
168+
SendGrid sendgrid = new SendGrid("SENDGRID USERNAME", "SENDGRID_PASSWORD");
169+
HttpHost proxy = new HttpHost("server", 3128);
170+
CloseableHttpClient http = HttpClientBuilder.create().setProxy(proxy).setUserAgent("sendgrid/" + sendgrid.getVersion() + ";java").build();
171+
sendgrid.setClient(http);
172+
```
173+
154174
## [X-SMTPAPI](http://sendgrid.com/docs/API_Reference/SMTP_API/index.html)
155175

156176
The mail object extends the SMTPAPI object which is found in [STMAPI-Java](https://github.com/sendgrid/smtpapi-java).

0 commit comments

Comments
 (0)