Recent

Author Topic: Sending Email from FPC (non-Lazarus)  (Read 14912 times)

RegNatarajan

  • New Member
  • *
  • Posts: 28
Sending Email from FPC (non-Lazarus)
« on: June 08, 2014, 12:42:20 pm »
I'd like to send notification emails from my non-Lazarus FPC CLI program on Linux without having sendmail installed and without using an external mail server.

Delphi had some libraries years ago that acted as an SMTP server and let me accomplish that.

Are there any FPC equivalents?

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Sending Email from FPC (non-Lazarus)
« Reply #1 on: June 08, 2014, 12:55:08 pm »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: Sending Email from FPC (non-Lazarus)
« Reply #2 on: June 08, 2014, 01:05:55 pm »
A quick forum search unearthed this recent discussion.
http://forum.lazarus.freepascal.org/index.php/topic,24577.msg148053.html

I particularly liked the example in the last post :-)
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

RegNatarajan

  • New Member
  • *
  • Posts: 28
Re: Sending Email from FPC (non-Lazarus)
« Reply #3 on: June 08, 2014, 11:53:34 pm »
Thank you for these replies.  Both refer to Synapse, which as far as I can see requires an external mail server.  I can't use that for my needs.  It has to work without an external mail server.  Any further thoughts would be welcome.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12645
  • FPC developer.
Re: Sending Email from FPC (non-Lazarus)
« Reply #4 on: June 09, 2014, 12:24:48 am »
Thank you for these replies.  Both refer to Synapse, which as far as I can see requires an external mail server.  I can't use that for my needs.  It has to work without an external mail server.  Any further thoughts would be welcome.

SMTP is always to an external mailserver.

RegNatarajan

  • New Member
  • *
  • Posts: 28
Re: Sending Email from FPC (non-Lazarus)
« Reply #5 on: June 09, 2014, 12:28:56 am »
SMTP is always to an external mailserver.
Of course the destination is to a mail server.  The sending program does not need to use one in order to send if it has the necessary libraries.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12645
  • FPC developer.
Re: Sending Email from FPC (non-Lazarus)
« Reply #6 on: June 09, 2014, 12:37:22 am »
SMTP is always to an external mailserver.
Of course the destination is to a mail server.  The sending program does not need to use one in order to send if it has the necessary libraries.

Synapse doesn't need external libraries for smtp. It might need SSL for SMTPS, but that can be staitically linked in with some work.

 Of course nowadays hardly any servers accept mail from unverified sources (e.g. not accepting mails when the IP of the mailserver don't match with the MX record of the senders  domain email addr)

In the old days before the spam problem emerged that was easier, but those days are long gone.

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Sending Email from FPC (non-Lazarus)
« Reply #7 on: June 09, 2014, 01:26:57 am »
It seems that RegNatarajan wants to have its own "embedded" SMTP server, unless I've wrongly interpreted his first post.

In this case, Indy is a possible solution (don't know it's also possible with Synapse).

There is a very old (probably outdated) demo for a simple SMTP server with Indy : http://indy.fulgan.com/ZIP/Indy10demo.zip (see SMTPServer subdirectory).

I guess more recent samples are available over the net, as Indy is widely used, at least with Delphi.

RegNatarajan

  • New Member
  • *
  • Posts: 28
Re: Sending Email from FPC (non-Lazarus)
« Reply #8 on: June 09, 2014, 04:45:15 am »
It seems that RegNatarajan wants to have its own "embedded" SMTP server
Yes, that's what I was trying to say, but couldn't find the right words.  Thank you.  I'll check out Indy.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Sending Email from FPC (non-Lazarus)
« Reply #9 on: June 09, 2014, 10:07:54 am »
@RegNatarajan: just out of curiosity: why did you decide to use Indy rather than Synapse? (I've always used Synapse myself; Indy just seems too tricky to install but perhaps things have improved)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Sending Email from FPC (non-Lazarus)
« Reply #10 on: June 09, 2014, 11:21:53 am »
does synapse have an SMTP server component (not client this is crucial for mailing lists with out an email server)?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Sending Email from FPC (non-Lazarus)
« Reply #11 on: June 09, 2014, 11:31:49 am »
Maybe I'm misunderstanding something here but:
1. smtp client: can connect to server on (e.g.) port 25 and send mail
2. smtp server: accepts connections on (e.g.) port 25
Why would you need to have 2. to be able to send mail? Or have I misread what RegNatarajan actually wants? Does he e.g. want to set up his own mailing list server or something?
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: Sending Email from FPC (non-Lazarus)
« Reply #12 on: June 09, 2014, 11:37:18 am »
It seems that RegNatarajan wants to have its own "embedded" SMTP server
Yes, that's what I was trying to say, but couldn't find the right words.  Thank you.  I'll check out Indy.
@Bigchimp Looks to me like it's your second scenario he's after.
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

bigeno

  • Sr. Member
  • ****
  • Posts: 266
Re: Sending Email from FPC (non-Lazarus)
« Reply #13 on: June 09, 2014, 02:07:20 pm »
Maybe I'm misunderstanding something here but:
1. smtp client: can connect to server on (e.g.) port 25 and send mail
2. smtp server: accepts connections on (e.g.) port 25
Why would you need to have 2. to be able to send mail? Or have I misread what RegNatarajan actually wants? Does he e.g. want to set up his own mailing list server or something?
He need smtp server to send mail directly to destination server.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Sending Email from FPC (non-Lazarus)
« Reply #14 on: June 09, 2014, 02:17:10 pm »
@bigeno: yes, he mentioned that. As marcov already indicated, in the past all you had to do is connect to the server using my method 1 and send.
Nowadays, you have SPF, DKIM and all kinds of other acronyms. Do you mean that option 2) in e.g. the Indy example covers all of that, enough so that sending from a (presumably) dynamic IP address directly to a remote mail server is possible?
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

 

TinyPortal © 2005-2018