Email relay functionality ending October 2020. Do not use.
The server uses JSONP to circumvent cross-domain AJAX limitations. To make a request, point the src
attribute of a script tag to emailrelay.henrygd.me/sendmail
, with the proper parameters included in the url. You must have a callback
param, which is the function used to process the returned JSON object.
In the example below, the returned data is passed to the function processResponse
to do the work. Some JavaScript libraries (like jQuery) have built-in methods for JSONP, so check the docs if you want to use that. Alternatively, I have a ready made form with baked-in support available here.
function sendEmail(key, email, fromEmail, name, message, subject, phone) {
var url = 'https://emailrelay.henrygd.me/sendmail?' +
// your key
'key=' + key +
// your email
'&email=' + encodeURIComponent(email) +
// sender's email (max 255 characters)
'&fromEmail=' + encodeURIComponent(fromEmail) +
// sender's name (max 255 characters)
'&name=' + encodeURIComponent(name) +
// message body (max 10000 characters)
'&message=' + encodeURIComponent(message) +
// Optional email subject (max 400 characters)
'&subject=' + encodeURIComponent(subject) +
// Optional phone number (max 50 characters)
'&phone=' + encodeURIComponent(phone) +
// callback function (max 255 characters)
'&callback=processResponse';
var script = document.createElement('script');
script.onerror = function() {
console.log('error');
};
script.src = url;
document.body.appendChild(script);
}
// function we passed in is automatically called upon receiving json response
window.processResponse = function(data) {
if (data.sent)
console.log("Success: " + data.remaining + " sends remaining");
else
console.log("Error: " + data.message)
}
EXAMPLE CASE | JSON RESPONSE |
---|---|
Successful send |
{"sent": true, "remaining": 44} |
Missing parameter |
{"sent": false, "message": "Missing name parameter"} |
Email / key mismatch |
{"sent": false, "message": "Email and key do not match"} |
Param exceeds length limit |
{"sent": false, "message": "Message is too long"} |
Exceeded weekly limit |
{"sent": false, "message": "You have reached the weekly limit"} |
Note: All emails are sent from emailrelay@henrygd.me. The reply-to header field will contain the sender's address, so please reply directly. No mail content or personal information is stored on this server. Numbers reset every Sunday at 12 AM (ET).