SMTP and HTTP Request

SMTP and HTTP Request

Vinay_S_Jindal
Not applicable
169 Views
2 Replies
Message 1 of 3

SMTP and HTTP Request

Vinay_S_Jindal
Not applicable

[ FlexSim 23.0.0 ]

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: jal.business.process@gmail.com\r\nTo: vinay.s@jindalaluminium.com\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();
0 Likes
Accepted solutions (1)
170 Views
2 Replies
Replies (2)
Message 2 of 3

Ben_WilsonADSK
Community Manager
Community Manager
Accepted solution

@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.

Message 3 of 3

jason_lightfoot_adsk
Autodesk
Autodesk

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