In my app, I need to send a confirmation e-mail to some customers every time some operation is finished.
How should I design, or what's best practice, the logic behind the smtp connection?
Should I connect authenticate the mail account and keep this connection open while the app is running (sometimes a couple of hours, with sometimes 20-30 minutes without any mail
Or should I close connection every time a mail is sent? Eventhough a mail can be sent multiple times a second on some operations...
I'm sending mails simply by telnetting to a remote webserver mail app.
This app can be used be multiple users at the same time using the same e-mail account.
So I need advice from people with experience in smtp behaviour and habits, How does a simple mail app works on this point?
You may keep SMTP connections open for a few minutes.
e.g. Default Sendmail configuration caches 2 connections for up to 5 minutes when processing queued messages. Sendmail issues RSET command to check cached connections before reuse. Issuing RSET is a good way to reset SMTP session to known state.
Related
I'm debugging a mail relay by running it and Thunderbird locally on a Linux box. This works as expected: Thunderbird carries out an SMTP transaction to localhost:25, the relay gets the message, and passes it on. This all happens 'immediately'.
Something strange happens when I move this test setup to the real world. The relay is running on a VPS out on the net. My local Thunderbird on Windows talks to an SMTP mail server at my ISP. My ISP then looks up the mail relay, and talks SMTP to the relay.
Here's where it gets interesting. The ISP sends a DATA command to the relay, and the lines of the message. It then sends .\r\n, as expected. The relay then responds with 250 OK\r\n. The ISP then waits one minute before sending QUIT\r\n.
Any idea what's going on here, and whether I can 'fix' this? My initial thought was that my ISP (Plusnet) is just trying to rate-limit me, but it doesn't insert a delay when I send a test message through to my own mail server. So, I click 'Send' in Thunderbird, the message goes out through Plusnet, and arrives back in Thunderbird in a couple of seconds.
Many MTA/SMTP servers cache for reuse existing SMTP connections.
Try sending a few messages a few seconds apart.
If you want more details provide name of SMTP server used by your ISP (postfix/sendmail/exim/…).
This question is not 100% technical. I've looked online and I couldn't find this being discussed.
We have a forgot username feature in our website which mails the username to the user's email address, using our own mail server.
We also put a message in the web-page asking the user to wait for 20 minutes for the mail to arrive since there can be occasional delays.
Our business tester raised an interesting point saying that 20 minutes seems an unacceptable time to ask the user to wait for. He said our technology should send emails immediately and the maximum lag should be 1 minute at worst.
Firstly, emails are usually received immediately by the recipient so there isn't a problem there.
But in our experience in using other websites, sometimes emails do take a while to arrive. I also remember reading somewhere that emails (at a network level) use a lower quality of service QoS unlike voip services. I can't seem to find it now.
Users can also experience delays in receiving emails because of issues in their own mail server.
Now, all we can do is send the mail using our mail server and ensure that the load and resources on the server is well managed.
1) Is there anything else we can do to ensure that our mails are sent quickly at all times.
2) What is the acceptable time, we can ask the user to wait until he logs a call with help-desk? I believe that there can be lags at a network/protocol level and the user's mail server which we can't do anything about.
Thanks.
All you can do is to inform user that your server "handed over" responsibility for email delivery to named SMTP server "beyond your control/responsibility". You may expect it would take a few (<5s) in most cases (>50%).
Your smtp-client may try initial delivery attempt.
On delivery success => inform the user that email delivery/delay is now beyond your control
On (initial) delivery failure => pass message to your SMTP server (with initial delivery attempt skipped).
The Send-MailMessage command is great for what it is, but if I wanted to send hundreds (or thousands) of messages over SMTP, that would require hundreds\thousands of separate SMTP sessions.
Is there a way in PowerShell to submit multiple messages over SMTP with a single SMTP connection?
For example, I have 100 emails to send. Each email is unique (different set of recipients,sender, subject, and body). This isn't a case where I want to send a single email to multiple recipients. I'm looking to send SMTP mail over a single connection to the SMTP server and not open 100 separate SMTP connections to send my 100 e-mails.
So I did a little testing by doing some network traces and interestingly enough when Send-MailMessage is used it opens a connection to an SMTP server and never closes it (so long as that PowerShell session I'm running is open). So this more or less solves my problem. I had always assumed that when Send-MailMessage is run it actually closes the connection when it is done, but it doesn't until the SMTP server forcibly closes it or the PowerSHhell process is closed.
The more you know.
The documentation says that "To" property is a collection. So you should be able to specify more than one email address at once without a need of one connection per recipient.
I have an e-mail account with hostgator. I would like to build a console application (later a service application) that will check a mysql database for e-mails that need to be sent out and will process them by sending a certain number of e-mail every so many seconds. These e-mails will each have a 2-3mb pdf price sheet attached to be sent to our regular customer base. About 500 are set up to receive e-mails.
My question is: Should I connect to hostgator directly and send the
e-mails or should I use the IIS Virtual Server Relay and have it
connect to hostgator?
The only thing I can think of is if Hostgator were down the virtual relay might be a good option since it has retries. There again, I guess I could put some try/catch in the code where if it doesn't connect to hostgator or if their is a problem it will go to the timer and wait x minutes before retrying to process e-mails.
We have found that the easiest approach is to generate the outgoing emails and drop them in the inetpub\mailroot\pickup folder and let the SMTP service handle them (you can set it up to forward the emails to the appropriate host).
This falls firmly under the category of not re-inventing the wheel: the SMTP service easily handles the situation when the connection to the mail server is down, retries, and all of the other "fun" stuff that you would otherwise have to implement in your code if you handle the SMTP sends directly.
I am trying to have a kind of observer pattern in ColdFusion
We want to listen to the incoming Email messages and act on them. Scenario is something like this :
Application sends email to the helpdesk system
Helpdesk system automatically generates a ticket and responds with an email to the email address of the application
The application's email is configured in the Lotus notes
Now the application should listen to this incoming email message, decode that and update the coressponding ticketid
I see there is a possibility with Event Gateways, but I am unable to realize the whole picture.
Thoughts or suggestions?
One way is to setup an email server with IMAP support, and use some sort of polling (every minute, good enough?) in CF using <cfimap> to get the emails.
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS371453EC-36D5-44ce-BF1E-750E3016BBD6.html
We have a system like this.
We have a postfix server configured to handle mail for a domain. A small script (Perl) on the postfix server places each email on an ActiveMQ queue.
We have a cluster of CF boxes with the ActiveMQ event gateway listener that takes the messages off the queue and processes them using Java Mail.
The delay between postfix receiving the email and a CF server processing it is generally under 1s.
We needed to do it this way for a number of reasons, processing delay being one of them, dealing with a large cluster of CF which made the POP/IMAP solution complicated, and CF's mail handling not being quite what we wanted were others.
It works great.
I've created similar applications in the past using cfpop to interogate a mailbox on a scheduled basis.
It was pretty easy to write, but usually gets thrown for a loop when "users" start being "helpful" with the email content.
The other thing is that this isn't instantaneous, but is the process really time critical to the second?