Did you have enabled external smtp usage in your google account and your smtp client is accepted via Oauth2?Sorry, I don't understand a single word from this.
You are not allowed to just use smtp.gmail.com with your normal username and password.Did you have enabled external smtp usage in your google account and your smtp client is accepted via Oauth2?Sorry, I don't understand a single word from this.
How can I do these?
... and others, but nowhere mentioned that other "tricks" are also needed to get it working. :(That's because they used to work fine. But Google keeps restricting the use because of security.
And what about to use not use Gmail as SMTP, but my internet provider's SMTP?You probably can use your providers smtp just fine (with or without SSL and authentication).
[...] but nowhere mentioned that other "tricks" are also needed to get it working. :(
And what about to use not use Gmail as SMTP, but my internet provider's SMTP?
I just tried with the PHPMailer and it worked perfectly if I gave these values into it:In that case you still have your gmail account set to insecure.
Is it possible to use Indy with these data?Yes, it should be possible to use these settings.
I think a Memo or ListBox could be good for showing the selected files, but how can the program "remember" their path during send-process?Create a TStringList with all the files you want to attach (including their path). Fill the TListBox according to this TStringList (in correct order) with only the filename. When the user wants to delete number index 2 of the TListBox, delete the TStringList[2] too. The TStringList will be the basis for sending the attachments.
Yes, my idea was similar, thank you for the confirmation.I think a Memo or ListBox could be good for showing the selected files, but how can the program "remember" their path during send-process?Create a TStringList with all the files you want to attach (including their path). Fill the TListBox according to this TStringList (in correct order) with only the filename. When the user wants to delete number index 2 of the TListBox, delete the TStringList[2] too. The TStringList will be the basis for sending the attachments.
You are not allowed to just use smtp.gmail.com with your normal username and password.
You can either implement OAuth2, which I imagine is beyond your skillset, or you need to use a "App password" instead of your normal gmail password.
I added the TIdSSLIOHandlerSocketOpenSSL component to the form and set its port. After it I could change the UseTLS to 'utUseRequireTLS' in SMTP.
1./ Are you getting no Background color or is it not behaving as expected?1./ I got no background-color.
2./ You can't enable SSLv1,2,3, it's an insecure protocol and shouldn't be used. I believe that is why he said use "utUseImplicitTLS on port 465', make sure it uses TLS on both ports.
2./ As I can see, the ipHtmlPanel cannot handle the formatting properlyThis is not normal HTML formatting for an E-mail client. You need to lookup how you need to encode correct HTML. If you send an E-mail to yourself and look at the source you'll see why.
(for example, this <p style="background-color: #627E20; font-weight: bold; color: #BAF2F2" >This is an other text.</p> does proper font formatting, but not for the background color).
This is not normal HTML formatting for an E-mail client. You need to lookup how you need to encode correct HTML. If you send an E-mail to yourself and look at the source you'll see why.Uh, thanks. It's new to me, I thought it is the usual html/css thing.
Your example should probably be something like this (the equal sign needs to be encoded with =3D):
<p style=3D"background-color: #627E20; font-weight: bold; color: #BAF2F2">This is an other text.</p>
Not sure if Indy does this automatically or has some functions available for it.
Uh, thanks. It's new to me, I thought it is the usual html/css thing.In essence it is. But using mail the html gets send as printed-quotable. And there the = sign is reserved for encoding. So = needs to be (re)encoded as =3D. $3D is ascii 61 which is the =.
You might need to patch to get background-color to work properly. I tried myself even encoding the = to %3D, as I expected it wouldn't work.No, don't encode it as %3D. Encode it as =3D.
No, don't encode it as %3D. Encode it as =3D.Yes, you are right, this is the proper way: style=3D"background-color: ...
Those are two different encodings.
One is url encoding and the other is printed-quotable.
1) MSG.From.Name := 'Your Name';
For my own curiosity :
Is correct? Not working for me.
Update: meanwhile I found this https://www.indyproject.org/2005/08/17/html-messages/ (https://www.indyproject.org/2005/08/17/html-messages/), not seems too simple.
Html-format: yes, strange. In idHtmlPanel it doesn't work, but I looked at the email source in TB and there was this 3D addition. Seems that idHtmlPanel cannot handle it.That's because idHtmlPanel just shows pure HTML. It doesn't take the printed-quotable into account. So before you show it in an HTML panel you need to convert the printed-quotable back to pure HTML.
1./ Currently the "From" contains my email address, but my name would be better there. Is it possible?
3./ The sending function works great with TLS and port 587 (Gmail). What should I change in the settings to get SSL and port 465 to work? I mean, there are many options in TIdSSLIOHandlerSocketOpenSSL for SSLOptions, bit confusing.
4./ Currently I'm using this method for attachment:It only send 1 attached file. How can I send more than 1 attached files?
Attachment := TIdAttachmentFile.Create(MailMessage.MessageParts, attFile);
4. is solved with a loop:
for i := 0 to slAttachedFiles.Count - 1 do begin if FileExists(slAttachedFiles[i]) then TIdAttachmentFile.Create(MailMessage.MessageParts, slAttachedFiles[i]); end;
Your example should probably be something like this (the equal sign needs to be encoded with =3D):
<p style=3D"background-color: #627E20; font-weight: bold; color: #BAF2F2">This is an other text.</p>
Not sure if Indy does this automatically or has some functions available for it.
Yes, by default Indy encodes plain-text using the "quoted-printable" algorithm (which is what encoded '=' as '=3D'), so DO NOT encode the HTML text manually.Then why didn't it work for justnewbie? And why did it work when doing it manually?
That's because idHtmlPanel just shows pure HTML. It doesn't take the printed-quotable into account.
So before you show it in an HTML panel you need to convert the printed-quotable back to pure HTML.
PS. If you got incoming mail, the HTML could also be base64 encoded.
And don't get me started about Outlook/Exchange which might even give you a winmail.dat with the text inside encoded (which not many other E-mail clients besides Outlook itself can decipher).
Then why didn't it work for justnewbie? And why did it work when doing it manually?
<!DOCTYPE html>When I put the 3D, nothing changed in the idHtmlPanel.
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p style="background-color: #A7E615;">This is a text.</p>
<p style="background-color: #627E20; font-weight: bold; color: #BAF2F2" >This is an other text.</p>
</body>
</html>
Based on this http://wiki.freepascal.org/TIpHtmlPanel (http://wiki.freepascal.org/TIpHtmlPanel), I made an on-the-fly stuff by using this html code:Quote<!DOCTYPE html>When I put the 3D, nothing changed in the idHtmlPanel.
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p style="background-color: #A7E615;">This is a text.</p>
<p style="background-color: #627E20; font-weight: bold; color: #BAF2F2" >This is an other text.</p>
</body>
</html>
I experienced a few hours difference between the real sending time (my local time) and the email's date/time.
How can I solve this?
Update: I found this http://www.delphipages.com/forum/showthread.php?t=182465 (http://www.delphipages.com/forum/showthread.php?t=182465), but it is wrong.
None of the Time(), Date() or Now() gave proper value.
Is it a bug?
Furthermore, DateTimeToStr(OffsetFromUTC()) gives 30-12-99.
Furthermore, DateTimeToStr(OffsetFromUTC()) gives 30-12-99.
TDateTime represents dates as an integral number of days relative to December 30 1899. Which means that OffsetFromUTC() is returning 0, either because:
[... etc ...]
My machine runs a Linux system and all Time(), Date() and Now() works well.
So, how can I get the proper "email-time"? If I send the email to myself for example at 14:32 (my local time), my email client shows 15:32. What should I set to get the proper 14:32?
And, as I mentioned above, something strange happens in my editor.
There is a TIdSMTP component on the form named SMTP. When I type SMTP in the editor, and after it I type a dot, instead of code completition bubble I got this idGlobal error, see picture. Why?
The UTCOffsetToStr(OffsetFromUTC()) gives +0000, which is incorrect.
I'm using Linux and its time display is good.
Thank you Lucamar, I'm trying to translate it.
Well, I found that Remy already wrote this: https://github.com/IndySockets/Indy/issues/245 (https://github.com/IndySockets/Indy/issues/245)
But, to be honest, I dunno what should I do based on this info.
GetLocalTimeOffset() gives the proper offset (in minutes). How can I pass this value to the Indy?
IIRC, TDateTime is a floating point value: the date is represented in the integral part (as days after 1899-12-30) and the time in the decimal part as a fraction of the day.
If OffsetFromUTC() returns a TDateTime or TTime value, then the "date" part will be 0, i.e. 1899-12-30 no matter what is in the "time" part.
Unless the offset is greater than 24 hours, of course :D
So, how can I get the proper "email-time"? If I send the email to myself for example at 14:32 (my local time), my email client shows 15:32. What should I set to get the proper 14:32?
Somehow Lazarus CodeTools barfs on that line. Solution is to modify that line so it looks like (or close) this:
Index: IdGlobal.pas =================================================================== --- IdGlobal.pas (revision 5496) +++ IdGlobal.pas (working copy) @@ -1905,7 +1905,8 @@ {$IFDEF UNIX} // For linux the user needs to set this variable to be accurate where used (mail, etc) - GOffsetFromUTC: TDateTime = 0{$IFDEF HAS_DEPRECATED}{$IFDEF USE_SEMICOLON_BEFORE_DEPRECATED};{$ENDIF} deprecated{$ENDIF}; +(* GOffsetFromUTC: TDateTime = 0{$IFDEF HAS_DEPRECATED}{$IFDEF USE_SEMICOLON_BEFORE_DEPRECATED};{$ENDIF} deprecated{$ENDIF}; *) + GOffsetFromUTC: TDateTime = 0;(*{$IFDEF HAS_DEPRECATED}{$IFDEF USE_SEMICOLON_BEFORE_DEPRECATED};{$ENDIF} deprecated{$ENDIF}; *) {$IFDEF DARWIN} GMachTimeBaseInfo: TTimebaseInfoData;
The UTCOffsetToStr(OffsetFromUTC()) gives +0000, which is incorrect.
I'm using Linux and its time display is good.
Well, I found that Remy already wrote this: https://github.com/IndySockets/Indy/issues/245 (https://github.com/IndySockets/Indy/issues/245)
But, to be honest, I dunno what should I do based on this info.
GetLocalTimeOffset() gives the proper offset (in minutes). How can I pass this value to the Indy?
Can you please confirm whether both UNIX and either KYLIXCOMPAT or USE_BASEUNIX are defined while compiling IdGlobal.pas when building Indy?
If both are defined, OffsetFromUTC() calculates an offset based on the Posix gettimeofday() function.
If either are not defined, OffsetFromUTC() falls back to Indy's GOffsetFromUTC variable, which is 0 by default and must be set manually. In which case, this is a bug in Indy, as those conditionals SHOULD be defined when compiling for Linux.
I have already considered using FPC's offset functions and am hesitant to use them because FPC's own documentation states that they return stale data after DST changes. So I haven't applied any fixes to Indy yet.
It also shows the solution: caling unix.ReReadLocalTime before GetLocalTimeOffset.
It also shows the solution: caling unix.ReReadLocalTime before GetLocalTimeOffset.
Yes, I know, but WHEN should that be called?
Note that on Linux/Unix, this information may be inaccurate around the DST time changes (for optimization). In that case, the unix.ReReadLocalTime unit must be used to re-initialize the timezone information.and, for ReReadLocalTime:
To speed up conversion of epoch (UTC) time to local time, the timezone information is loaded only once, at program startup. Calling this routine re-reads the timezone information using current timezone settings.
to be absolutely sure it's never out of synch one should do something like:
function GetRealLocalTimeOffset: Integer; begin unix.ReReadLocalTime; {ifdefed for UNIX, of course} Result := GetLoaclTimeOffset; end;
Is that thread-safe, though?
How can I send the same emails to all with this unique part inside (ie. how can I update only the message body part)?
Now I cannot send attachments (it worked before this modification you gave).
Now I got a '... raised exception class 'External: SIGKILL'.'
What does cause this?
My code was made based on those webpages.
What are those missing parts? Cannot see them, I think my code is complete.