Recent

Author Topic: Guidance on email using Synapse and SMTPsend  (Read 495 times)

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 564
Guidance on email using Synapse and SMTPsend
« on: October 30, 2024, 09:05:22 pm »
I need to send some instrument readings to an email address every two or three hours, and have been trying to get Example 4 of of the Synapse Email examples (https://wiki.lazarus.freepascal.org/Synapse_-_Email_Examples) to work. 

o  I can compile the example and execute it through "SMTP Login: OK', but I get a bunch of errors thereafter as shown here:

Code: Pascal  [Select][+][-]
  1. SMTP Login: OK
  2. -- Remote response:
  3. SMTP: outbound.att.net supports ESMTP
  4. SMTP ERROR: MailFrom:???-Other undefined Status
  5. SMTP ERROR: MailTo:???-Other undefined Status
  6. SMTP ERROR: MailData:???-Other undefined Status
  7. SMTP ERROR: Logout:???-Other undefined Status
  8.  

o  When I try to step into the Synapse SMTPsend unit's MailFrom function, get the error
Code: Pascal  [Select][+][-]
  1. "Project project1 raised exception class 'External: Unknown exception code 13'.
  2.  At address B7F41D09
  3.  

Any thoughts on why I can't step into SMPTsend code would be gratefully appreciated -- as would any other ideas on what I'm doing wrong in general.  I've never tried to do anything with the internet or Synapse before so don't really know what I'm doing.  The "SMTP login: OK" seems to indicate that something is working but I can't seem to get anywhere with debugging the problems on my own.

Thanks. 

rvk

  • Hero Member
  • *****
  • Posts: 6585
Re: Guidance on email using Synapse and SMTPsend
« Reply #1 on: October 31, 2024, 09:56:55 am »
SMTP errorcode 13 seems to indicate "Permission denied (13)".

Did you try the exact example with:
Code: Pascal  [Select][+][-]
  1. SMTP.MailFrom(MailFrom, Length(MailFrom))

You might want to change that in this and see if it helps.
Code: Pascal  [Select][+][-]
  1. SMTP.MailFrom(MailFrom, 0)

Also... in case of error you could also try to print SMTP.FullResult[0] just to see if there is data in it.
So something like:
Code: Pascal  [Select][+][-]
  1. if not SMTP.MailFrom(MailFrom, 0) then
  2. begin
  3.   Form1.Memo1.Append('SMTP ERROR: MailFrom:' + SMTP.EnhCodeString);
  4.   Form1.Memo1.append('-- Remote response: ' + SMTP.FullResult.Text);
  5. end
  6. else
  7. begin
  8.   Form1.Memo1.Append('SMTP MailFrom: OK');
  9.   Form1.Memo1.append('-- Remote response: ' + SMTP.FullResult[0]);
  10. end;

BTW. The Size parameter for SMTP.MailFrom() should NEVER be the size of the From address. It should be the size of the entire mail or 0 (if the server can determine this itself). This is a really common made mistake.
« Last Edit: October 31, 2024, 10:00:06 am by rvk »

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 564
Re: Guidance on email using Synapse and SMTPsend
« Reply #2 on: October 31, 2024, 04:22:42 pm »
Thanks very much for the help rvk -- I'll try the length and full response changes this morning.

 

TinyPortal © 2005-2018