Skip to content

Instantly share code, notes, and snippets.

@kidGodzilla
Last active April 26, 2023 19:57
Show Gist options
  • Save kidGodzilla/bdd453129a1e30ac9d86b9fd7b412ca8 to your computer and use it in GitHub Desktop.
Save kidGodzilla/bdd453129a1e30ac9d86b9fd7b412ca8 to your computer and use it in GitHub Desktop.
MailThis.to Ajax Example
// The following example POSTS data to mailthis.to, redirects the user to a confirmation page, and then sends an email (upon the successful completion of Recaptcha verification)
$.post('https://mailthis.to/[email protected]', {
email: '[email protected]',
_subject: 'hi!',
message: 'Test'
}).then(function () {
location.href = 'https://mailthis.to/confirm'
});
@daksamedia
Copy link

I tried this up but none of this worked.

@erwindemoel
Copy link

Is it possible to use an ajax POST call, without having to redirect our users away from our website? We want to do an asychronous call in the backend to send our email without a redirect.

@CodeAlDente
Copy link

You received this because you signed up for MailThis.to, a form to email se=
rvice. <br><br><br><br>Have a Wonderful Day!<br><br><img src=3D"https://u94=
00108.ct.sendgrid.net/wf/open?upn=............../>

ref https://sendgrid.com/docs/ui/account-and-settings/tracking/#open-tracking

A tracking pixel inside the mail. Come on @kidGodzilla, seriously?

@kidGodzilla
Copy link
Author

Original author here. Thanks for your comments, I didn't get these replies because the service was sold a few years back.

However, it appears it was abandoned by the purchaser, and I have began restoring service. Things should be online now.

@CodeAlDente This appears to be a SendGrid default, or something enabled recently by the previous owner. I'll take a look.

@skiwheelr
Copy link

How can i send a file using this?
I learned that $.post cannot be used to send a file, so i need to use $.ajax.
What would the syntax be?

@skiwheelr
Copy link

skiwheelr commented Sep 15, 2020

export const SendMail = () => {
	// $.post('https://mailthis.to/[email protected]',{
	// 	email: '[email protected]',
	// 	_subject: 'hi!',
	// 	message: 'Test',
	// 	file: './dgsl.png'
	// }).then(function () {
	// 	window.location.href = 'https://mailthis.to/confirm'
	// });

	$.ajax({
		url: 'https://mailthis.to/ski******@gmail.com',
		type: 'post',
		data: {
			email: '[email protected]',
			_subject: 'hi!',
			message: 'Test',
			file: './dgsl.png'
		},
		headers: {
			encType:'multipart/form-data',
		},
		dataType: 'json',
		success: function (data) {
			console.info(data);
		}
	});
};

@mhadianfard
Copy link

Not sure if anyone is still working on this project, but the basic HTML form isn't redirecting people back to where they should go using the following input tag:

.... anyone else have this problem?

not even trying to do anything with JS.

@Nikita244
Copy link

hello
Can i change this? location.href = 'https://mailthis.to/confirm'
im working on angular and if i delete this code part, the email dosent arrived.
thanks a lot

@ramit-mitra
Copy link

Hi @Nikita244 you need to submit the form to mailthis.to else the form data will not get processed, and neither will you get the submission email. MailThis processes the form submission data and sends out the email so your form needs to submit the formdata to mailthis. Hope it helps!

@Nikita244
Copy link

Nikita244 commented Dec 30, 2022 via email

@anbu-ops
Copy link

Can someone provide how does this work in angular

@ramit-mitra
Copy link

Can someone provide how does this work in angular

The example is pretty self explanatory. I remember having implemented in AngularJS years ago and it worked fine. So IMO the above should work fine for Angular & React. Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment