Forum > General
sending email not working
MarkMLl:
Yes, that is for output and works with a program that runs until it gets a sigint or sigterm.
If a program is terminating immediately it sees no input and doesn't have an option to run until it sees an explicit EOF (i.e. pipe closure etc.) then it's obviously a problem. OTOH my experience with things like sendmail was that they ran until they got an explicit EOM, e.g. . as the first character of a line.
MarkMLl
Remy Lebeau:
--- Quote from: rvk on June 13, 2024, 07:49:55 pm ---And if the command sees there is no bytes in the inputstream it could quit directly.
So my guess was that you first need to begin filling the inputstream before you do Execute.
Unless the command really waits before any input (which isn't certain).
--- End quote ---
According to https://marlam.de/msmtp/msmtp.html:
--- Quote ---In its default mode of operation, it reads a mail from standard input...
--- End quote ---
So, it's safe to assume that it waits for the caller to enter input so it knows what to send.
TRon:
I am also not familiar with the details of such piping as shown by your example Remy but could it perhaps be that msmtp sits and (ultimately) waits for a terminating character such as CR/LF or EOF ? (I am unfamiliar with what the piped stream actually sends to the command)
MarkMLl:
--- Quote from: TRon on June 14, 2024, 06:54:47 am ---I am also not familiar with the details of such piping as shown by your example Remy but could it perhaps be that msmtp sits and (ultimately) waits for a terminating character such as CR/LF or EOF ? (I am unfamiliar with what the piped stream actually sends to the command)
--- End quote ---
Or a dot at the start of a line, possibly by itself. That was "the UNIX way" in days of yore.
MarkMLl
rvk:
--- Quote from: Awesome Programmer on June 13, 2024, 05:16:11 pm ---
--- Quote from: Remy Lebeau on June 12, 2024, 10:10:58 pm ---
--- 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";}};} ---sp.Executable := 'msmpt';
--- End quote ---
When I run your code, it hangs up on L.LoadFromStream(sp.Output);. The program doesn't freeze or crash. It is just sitting at that line for an output from the command, but there is NO output from the command. Command executes and exits without no output. So, I not sure why this is.
--- End quote ---
You did change the msmpt to msmtp, didn't you? ;)
I did a quick test. There is no output so if you comment out the reading of the non-existing output, it will go through.
--- 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";}};} ---program mailtest;{$MODE OBJFPC}{$H+}uses classes, sysutils, process; const frommail = 'me@meme.com'; tomail = 'me@meme.com'; function foo(): Boolean;var sp: TProcess; L: TStringList;begin L := TStringList.Create; sp := TProcess.Create(nil); try sp.Options := [poUsePipes]; sp.Executable := 'msmtp'; sp.Parameters.Add('--from=' + frommail); sp.Parameters.Add(tomail); sp.Execute; L.Text := 'Hello World'; L.SaveToStream(sp.Input); { L.Clear; L.LoadFromStream(sp.Output); WriteLn(L.Text); } writeln('Exit status: ', sp.exitstatus); writeln('Exit code: ', sp.exitcode); finally sp.free; L.free; end; Result := true;end; begin writeln('Start'); writeln('Date = ', {$i %DATE%}); writeln('FPC target = ', {$i %FPCTARGET%}); writeln('FPC target CPU = ', {$i %FPCTARGETCPU%}); writeln('FPC target OS = ', {$i %FPCTARGETOS%}); writeln('FPC version = ', {$i %FPCVERSION%}); foo(); end.
--- Quote ---Start
Date = 2024/06/14
FPC target = aarch64
FPC target CPU = aarch64
FPC target OS = Linux
FPC version = 3.3.1
Exit status: -1
Exit code: 0
--- End quote ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page