Forum > General
sending email not working
Awesome Programmer:
my Lazarus compiler 2.0.0. Yes, Yes... I know it is sooooo old that I shouldn't use this version at all... lol... but it is working and compiling my code with NO ISSUES whatsoever. If I were to upgrade, it will break over 50% of all my components and LIBRARIES that means many of my codes/program will seize to compile forever. Just thought I'd let you all know, before you all jump on me for this... lol... :D
Anyways, I am trying to use the msmtp terminal command to send email messages. I have searched online for this command and found a lot of good information and samples. So, I was able to come up with a command line that works flawlessly. It sends email and I can even send SMS text message to smartphone. ONLY through TERMINAL or CONSOLE.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---echo "Hello world" | msmtp --from=James@James.com 1234567899@tmomail.net
However, this same commandline code WILL NOT execute from within Lazarus. No message box pops up or gives any hints or errors. I don't get SMS or EMAIL message either. The function is below.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function SendMail:Boolean;var sp:TProcess; L:Tstringlist;begin l:=tstringlist.create; sp:= Tprocess.Create(nil); try sp.options:=[poUsePipes]; sp.executable := 'echo'; sp.Parameters.Add('"Hello World"'); sp.Parameters.Add('|'); sp.Parameters.Add('msmpt --from=james@james.com 1234567899@tmomail.net'); sp.execute; l.SaveToStream(sp.Input); l.clear; l.LoadfromStream(sp.output); writeln(l.text); finally sp.free; l.free; end; result:=true;end;
Can someone tell me what is wrong with the above PASCAL CODE?
TRon:
--- Quote from: Awesome Programmer on June 12, 2024, 08:21:04 pm ---Can someone tell me what is wrong with the above PASCAL CODE?
--- End quote ---
TProcess is not a shell replacement.
Fibonacci:
I guess you should run "msmtp", not "echo", and then send there your text with pipes
MarkMLl:
--- Quote from: Awesome Programmer on June 12, 2024, 08:21:04 pm ---Can someone tell me what is wrong with the above PASCAL CODE?
--- End quote ---
Yes, RTFM:
--- Quote ---TProcess ... does not support complex pipelines as in Unix. If this behaviour is desired, the shell can be executed with the pipeline as the command it should execute.
--- End quote ---
https://www.freepascal.org/docs-html/current/fcl/process/index.html
Oh, and it's Pascal, not PASCAL.
MarkMLl
Awesome Programmer:
Yes, RTFM:
LOL... for your information, I always do my best to read and re-read TFM. Sometimes, things don't always work like they say in the BOOK... I learned this after coding for over 20 years.
I came up with a workaround and it works; created a shell script file and then execute the script file from my Lazarus program.
:D :D :D :D
Navigation
[0] Message Index
[#] Next page