question

Vinay S avatar image
0 Likes"
Vinay S asked Jason Lightfoot commented

SMTP and HTTP Request

Hi There,

I'm trying to send the mail using Flexsim HTTP API by Gmail SMTP.

I created gmail app password also.

I'm using below code to send but its not working. can you correct this

Http.Request r;
r.method = Http.Method.Post;
r.useSSL = 1;
r.port = 465;
r.host = "smtp.gmail.com";
r.path = "";
r.headers = "Content-Type: text/plain;charset=utf-8\r\nFrom: [email protected]\r\nTo: [email protected]\r\nSubject: JAL Test mail\r\nAuthorization: Basic amFsLmJ1c2luZXNzLmNvbS53anF1eWVsdWF4bXF2ZDp3anF1eWVsdWF4bXF2ZA==\r\nHello JAL BP.";
r.successCallback = model.find("/Tools/success");
r.failCallback = model.find("/Tools/fail");
r.send();
FlexSim 23.0.0
http request
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Vinay S, was Ben Wilson's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes 0 ·

1 Answer

Ben Wilson avatar image
1 Like"
Ben Wilson answered

@Vinay S ,

Supporting a particular HTTP endpoint is really beyond the scope of FlexSim support. Our support really should end with showing that FlexSim is properly sending the HTTP request. This answer shows a good example of how you can test FlexSim's HTTP functionality using the excellent test resource httpbin.org.

While Gmail does seem to support a RESTful API, there is a ton of behind the scenes setup necessary for the authentication side, which I don't see how you could encapsulate into the simple HTTP API available in FlexSim.

Your better bet would be to maintain a separate server, perhaps a PHP server as you mentioned here, that could accept your simple HTTP request sent from FlexSim. This server could use a package like PHPMailer to connect to Gmail and send your message.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.