I'm not sure, but if you only want to send an email from the code, I would
suggest to try SendToRaw function. It is possible to send to multiple
addresses, ccs, attachments.
Please bear in mind that there is a need to check the function in
smtpsend.pas file and uncomment TLS support.
You can find many examples in the forums; please also find below an example
of code. Of course it is only draft-idea, you have to add error handling,
etc.
var
message: TMimemess;
p: TMimepart;
message:=TMimemess.create;
try
p:=message.AddPartMultipart('mixed', nil);
message.AddPartHTML(email_content_here, p);
message.Header.Date:=Now;
message.Header.From:=sender_here;
message.Header.ReplyTo:=replyto_here;
message.Header.ToList.add(recipient_here);
message.Header.CCList.Add(cc_here);
message.Header.subject:=UTF8ToWinCP(subject_here);
message.Header.XMailer:='Your program name or something else_here';
message.AddPartBinaryFromFile(attachment_file_here, p);
message.Header.MessageID:=message_id_here // if you like
message.EncodeMessage;
if SendToRaw(sender, recipient_list, aserwer + ':' + aport, message.Lines,
auser, apassword) then
Result:=true
else
Result:=false;
finally
message.free;
end;
Hope it helps.
Regards
Michał
IT Pomoc Sp. z o.o.
Tel. 730 020 020
mail: <mailto:[email protected]> [email protected]
www: <http://itpomoc.pl/> http://itpomoc.pl
50-312 Wrocław, ul. Stefana Żeromskiego 62/2
Sąd Rejonowy dla Wrocławia Fabrycznej, VI Wydz. Gospodarczy KRS
KRS: 0000641889, Regon: 365639050, NIP: 898-222-49-68
Kapitał zakładowy: 20.000,00 PLN
Posiadamy certyfikat ISO 27001:2013 (Zarządzanie Bezpieczeństwem Informacji)
[PL] Ta poczta zawiera poufne lub prawnie chronione informacje. Jeżeli nie
jesteś prawnym adresatem lub otrzymałeś tą informację przez pomyłkę, proszę
o niezwłoczne poinformowanie nadawcy i zniszczenie tej wiadomości.
Kopiowanie, dalsze przekazywanie lub wykorzystywanie tej wiadomości jest
niedozwolone.
Informujemy, że Administratorem podanych przez Państwa danych osobowych jest
IT Pomoc Sp. z o.o. 50-312 Wrocław, ul. Stefana Żeromskiego 62/2. Więcej
informacji na naszej stronie internetowej w zakładce Kontakt.
[EN] This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden. Please be advised that the controller of
personal data provided by you is IT Pomoc Sp. z o.o. 50-312 Wrocław, ul.
Stefana Żeromskiego 62/2. More information about on our website in the
Contact tab.
From: S.C.T.N GmbH <[email protected]>
Sent: Saturday, March 12, 2022 4:51 PM
To: [email protected]
Subject: [Synalist] Need help with "How To Use SMTP with TLS"
Please I need help with the SMTP HOWTO especially with the format of the
sFileName file
// e-mail template (subject and other headers+CRLF+CRLF+e-mail body)
// in file sFileName
As I understand
- sFileName is loaded into the StringList
- From and To are inserted into the first two positions of the list :
msg_lines.Insert(0, 'From: ' + sFrom); //sFrom is my Yahoo mail adress
[email protected] <mailto:[email protected]>
msg_lines.Insert(1, 'To: ' + sTo); //sTo is my GMX e-mail
adress [email protected] <mailto:[email protected]>
- Then, how many CRLF do I have to add? And where do I place the Subject
line?
My sFile looks like this: (of course <CRLF> is only here for explanation
Subject: DAS MESSAGE <CRLF>
<CRLF>
<CRLF>
<CRLF>
<CRLF>
the quick brown fox <CRLF>
jumps over the lazy dog <CRLF>
My sample code is modified like this to simplify the whole thing:
if not smtp.Login() then writeln('SMTP LOGIN ERROR');
if not smtp.StartTLS() then writeln('STARTTLS ERROR');
if not smtp.MailFrom(sFrom, Length(sFrom)) then writeln('FROM ERROR');
if not smtp.MailTo(sTo) then writeln('TO ERROR');
if not smtp.MailData(msg_lines) then writeln('MAIL DATA ERROR');
if not smtp.Logout() then writeln('LOGOUT ERROR');
What I get on the console is:
- FROM ERROR
- TO ERROR
- MAIL DATA ERROR
I am trying Port 25 and 587: in both cases I get the 3 errors above
Mit freundlichem Gruß / Yours sincerely / Cordialement
Christian Sporer
Grüntenstr.18
80686 München
Tel.: +(49) 89 54217952
Fax.: +(49) 89 52389119
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public