Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions examples/helpers/inbound/java-send/default_data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
--xYzZY
Content-Disposition: form-data; name="headers"

MIME-Version: 1.0
Received: by 0.0.0.0 with HTTP; Wed, 10 Aug 2016 18:10:13 -0700 (PDT)
From: Example User <test@example.com>
Date: Wed, 10 Aug 2016 18:10:13 -0700
Subject: Inbound Parse Test Data
To: inbound@inbound.example.com
Content-Type: multipart/alternative; boundary=001a113df448cad2d00539c16e89

--xYzZY
Content-Disposition: form-data; name="dkim"

{@sendgrid.com : pass}
--xYzZY
Content-Disposition: form-data; name="to"

inbound@inbound.example.com
--xYzZY
Content-Disposition: form-data; name="html"

<html><body><strong>Hello SendGrid!</body></html>

--xYzZY
Content-Disposition: form-data; name="from"

Example User <test@example.com>
--xYzZY
Content-Disposition: form-data; name="text"

Hello SendGrid!

--xYzZY
Content-Disposition: form-data; name="sender_ip"

0.0.0.0
--xYzZY
Content-Disposition: form-data; name="envelope"

{"to":["inbound@inbound.example.com"],"from":"test@example.com"}
--xYzZY
Content-Disposition: form-data; name="attachments"

0
--xYzZY
Content-Disposition: form-data; name="subject"

Testing non-raw
--xYzZY
Content-Disposition: form-data; name="charsets"

{"to":"UTF-8","html":"UTF-8","subject":"UTF-8","from":"UTF-8","text":"UTF-8"}
--xYzZY
Content-Disposition: form-data; name="SPF"

pass
--xYzZY--
29 changes: 29 additions & 0 deletions examples/helpers/inbound/java-send/src/com/example/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example;

import java.io.IOException;
import java.io.OutputStream;
import java.net.*;
import java.nio.file.Files;
import java.nio.file.Paths;

public class Main {

public static void main(String[] args) throws IOException {

URL url = new URL(args[1]);
URLConnection con = url.openConnection();
HttpURLConnection http = (HttpURLConnection) con;
http.setRequestMethod("POST");
http.setDoOutput(true);

byte[] out = Files.readAllBytes(Paths.get(args[0]));
int length = out.length;

http.setFixedLengthStreamingMode(length);
http.setRequestProperty("Content-Type", "multipart/form-data; boundary=xYzZY");
http.connect();
try (OutputStream os = http.getOutputStream()) {
os.write(out);
}
}
}