Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: SMTP server in IW app?



Permlink Replies: 4 - Last Post: Apr 16, 2015 11:06 AM Last Post By: Daniel Fields
Eitan Arbel

Posts: 508
Registered: 2/24/13
SMTP server in IW app?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 13, 2015 10:43 AM
hi,.

i need the users of my app to be able to send many emails to their costumers.
the reason why i need a mail server of my own, is because i need to be able to send AND receive emails from and to "MyUser at MyAppSite dot com".
my app should be able to send email, and the SMTP server should "capture" mails sent to me (and to my users).
the SMTP server and my IW app/server, should both be on the same machine.

1. for some reason, the Indy 10 examples of SMTP mail servers sending mail, are not working on my XE5.
2. should the SMTP server be created INSIDE my IW app or should it be as an outside standalone server that i send parameters too? if this is the option to do it, then how please?

i use Delphi XE5, and IW14.0.39 if it helps

Thanks!

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: SMTP server in IW app?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 13, 2015 11:08 AM   in response to: Eitan Arbel in response to: Eitan Arbel
Eitan wrote:

1. for some reason, the Indy 10 examples of SMTP mail servers sending
mail, are not working on my XE5.

The TIdSMTPServer component is not widely used, so I'm sure there are not
too many examples of it, but I do know the component works in general. So
please show the actual code you are having trouble with.

2. should the SMTP server be created INSIDE my IW app or should it
be as an outside standalone server that i send parameters too? if this
is the option to do it, then how please?

I would think it needs to be a separate service of its own, since you want
to receive emails, so it needs to be running while IW is not running, or
is sitting idle.

You don't need TIdSMTPServer to send emails, only to receive them. To
send emails, you have to use TIdSMTP or TIdSMTPRelay instead. And then
when your app wants to pull received emails, you have to use TIdPOP3 or TIdIMAP4
(which means running a TIdPOP3Server or TIdIMAP4Server alongside TIdSMTPServer),
if you are not already running another POP3/IMAP4 server, or otherwise have
direct access to the mailboxes that your TIdSMTPServer saves emails to.
An SMTP client sends emails to an SMTP server. An SMTP server receives emails
and saves them into mailboxes. A POP3/IMAP4 client retreives emails from
those mailboxes.

--
Remy Lebeau (TeamB)
Daniel Fields

Posts: 622
Registered: 11/29/04
Re: SMTP server in IW app?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 13, 2015 11:27 AM   in response to: Eitan Arbel in response to: Eitan Arbel
How do you have the component setup? You need to have DNS setup on your server to make it work. Or, you have to be using a service that supports external usage. There is a great deal of protocol activity involved with sending email. Mail clients utilize DNS to determine the validity and threat level of incoming messages. You can make the message appear to come from anyplace by setting the properties to read as desired. The mail client tries to confirm that the message is being delivered from the same domain, and that the domain is properly configured. The SMTP Server component cannot handle any of that.

Do it as a standalone service! I once did it inside the ServerController and it made the entire system unstable. You are opening another port on your server so it will get probed and attacked. If you separate it from your main application, you can protect performance levels. If you need to scale, you could then run it on a different server.

Another option is to use Mail Enable to serve the mail functions. You could then turn off anything you do not need. The SMTP component would then connect to your own mail server where you would have control over the mailboxes. Mail Enable has been around a long time and is easy to use. There is paid support if needed, and you can buy 3rd party add-ins for additional security and virus scanning. This gives you a full, private mail system without any layers between it and your application. This also handles all of the DNS requirements automatically.

The most current way to do this is through a service with an API, such as MailGun (http://www.mailgun.com/). With this method you are using HTTP calls to send messages by passing parameters. You can use HTTP or SMTP with most services. MailGun is designed for developers and high-volume senders.
Eitan Arbel

Posts: 508
Registered: 2/24/13
Re: SMTP server in IW app?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2015 10:09 AM   in response to: Eitan Arbel in response to: Eitan Arbel
Thank you Remy and Daniel

i didn't use any email component in 9-10 years, so i guess i made a "mishmash" of definitions.
sorry about that...

yes, i need a something that will (probably) have some SMTP component to send mails, and (probably) a POP3 to receive.
i would prefer to have that inside my intraweb app/server so the maintenance will be easier in the same software, but also so it will be easy when i'll move my IW server to a stronger machine.

the thing is that these are not my mails.
my IW application, is for small business.
i have several small business connected to my server.
each of these small business, have costumers that they can send emails to.
some of these mails have PDF report attachments, and some have JPG graphs. all emails also have some text in it, and they should be sent as Text mails (not as html).

any idea how i should approach this please?
(some code would be GREATLY appreciated...)

Daniel, can you show me with some code, how to work with mailgun.com please?
i don't know how to use an outside service API...

my app is not "on the air" yet, so i would really prefer a free solution for now, or at least use components that came with Delphi.

Thank you very much for your help guys!

Daniel Fields

Posts: 622
Registered: 11/29/04
Re: SMTP server in IW app?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2015 11:06 AM   in response to: Eitan Arbel in response to: Eitan Arbel
I think Mailgun will work for you. The free account allows you to send/receive 10,000 messages per month. You have to use the paid option for anything above that. Once you create an account you can add your domain so that sending appears to come from your server. IF you want to receive through Mailgun, you will have to change records at your domain provider as well. You can keep receiving as you do now and only send through Mailgun if you want.

Your account is assigned SMTP credentials that you can then plug into the TIdSMTP Client component and send that way. You do not have to use the API. That way you can follow the examples that already exist for sending the attachments. That would be the fastest way to get started.

Where is your mail hosted now? Can you use it for SMTP sending? How much mail are you sending per month?
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02