Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
protogrid:json_api_endpoint_mailsend [2020-07-28 08:29] – [Example client-side jQuery function to send mail in web application] 85.1.6.98protogrid:json_api_endpoint_mailsend [2020-12-22 16:03] (current) – Hier gelöscht, da zwecks Konsistenzerhaltung in Haupt-Endpoint-Arikel (https://protogrid.wiki/protogrid/api_endpoints#apiv2appsapp_nameprotosproto_keycard-keys) übernommen dru
Line 1: Line 1:
-====== JSON API Endpoint mailsend ====== 
  
-/api/v2/apps/<app_name>/mailsend 
- 
-[GET, POST] Send an email using the provided data 
- 
-The following JSON data fields or URL parameters can be used: 
-  * to: TO address (multiple addresses separated by comma) 
-  * cc: CC address (multiple addresses separated by comma) 
-  * bcc: BCC address (multiple addresses separated by comma) 
-  * replyto: ReplyTo address 
-  * subject: Subject in plain text 
-  * body: Body text in plain text format (URL encoded) 
-  * bodyhtml: Body text in HTML format (URL encoded). If both body and bodyhtml are specififed, only bodyhtml will be used 
-  * attachments: weblink to attachment (URL encoded), multiple links separated by comma 
- 
-Combinations of JSON data fields and URL parameters are allowed, whereas JSON data fields take precendence over URL parameters 
- 
-The mail will be sent according to the currently logged in user (mail address specified in user profile, and the fields "SMTP Server Hostname", "SMTP Server Port" and "SMTP Server Password"). 
- 
-The function will fist try to establish a TLS session to the specified mail server and authenicate using the supplies credentials. If TLS is not available it will try to connect using SSL. Finally if SSL is not available the function tries to connect using unsecured SMTP protocol. 
- 
-The returned result will contain the key success with a value of true or a corresponding error message. 
- 
-Example request:  
-<code> 
-https://example.protogrid.com/api/v2/apps/example/mailsend?to=user1@example.com&cc=user2@example.com&subject=example&bcc=user@example.com&replyto=user@example.com&body=&bodyhtml=%3Chtml%3E%0A%3Cbody%3E%0A%0A%3Ch1%3EMy%20First%20Heading%3C%2Fh1%3E%0A%3Cp%3EMy%20first%20paragraph.%3C%2Fp%3E%0A%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E&attachments=https%3A%2F%2Fprotogrid.wiki%2Flib%2Ftpl%2Fpgrid-vector%2Fuser%2Flogo.png 
-</code> 
- 
-Example result: 
-<code json> 
-{ 
-   "errors" : [], 
-   "protogrid_environment_version" : "2.1.3", 
-   "result": {"success":true} 
-} 
-</code> 
- 
- 
-==== Example client-side jQuery function to send mail in web application ==== 
- 
-<code json> 
- 
-$.get("https://example.protogrid.com/api/v2/apps/example/mailsend?to=user@example.com&subject=Test&body=This%20is%20a%20testmessage", function(data, status){ 
-    alert("Data: " + JSON.stringify(data)); 
-  }); 
-   
-$.post({ 
-    url: "https://example.protogrid.com/api/v2/apps/example/mailsend", 
-    data: JSON.stringify({ 
- "to": "user@example.com", 
- "cc": "user2@example.com", 
- "subject": "Test", 
- "body": "This%20is%20a%20testmessage", 
- }), 
-    contentType: 'application/json; charset=utf-8' 
-}).done(function (response) { 
-        alert("Data: " + JSON.stringify(response)); 
-}); 
- 
-</code> 
Print/export