login about faq

Is it possible to send multiple outgoing emails to a SMTP server in one connection? I have a user who sends lots of emails and uses Google, Google has told him the emails should be sent all in one connection instead of one connection per email.

Would putting a loop like below use the same connection or create a new connection for each email?

'  Use the GMail SMTP server
mailman.SmtpHost = "smtp.gmail.com"
mailman.SmtpPort = 465
mailman.SmtpSsl = 1

'  Set the SMTP login/password.
mailman.SmtpUsername = "chilkat.support"
mailman.SmtpPassword = "myPassword"

**for a = 1 to 1000**

Dim email As New ChilkatEmail2
email.Subject = "This is a test" & a
email.Body = "This is a test" & a
email.From = "Chilkat Support <chilkat.support@gmail.com>"
email.AddTo "Chilkat","support@chilkatsoft.com"

success = mailman.SendEmail(email)
If (success <> 1) Then
    MsgBox mailman.LastErrorText
    Exit Sub
End If
**next a**

asked Apr 30 '13 at 10:34

Ron's gravatar image

Ron
1223


Yes, the Chilkat mailman will by-default keep the connection open with the SMTP server after an email is sent. This allows for a subsequent email to be sent on the same connection.

Make sure your program uses the same mailman object instance for each send. If you use different mailman instances, then each will have its own connection.

link

answered Apr 30 '13 at 10:47

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Would a loop like below use the same connection also? I realized my code already has a loop similar to below... will setting the mailmain host and password setting to the same value cause it to drop the current connection and create a new one on each pass? How long is a connection left open before it drops?

**for a = 1 to 1000**
'  Use the GMail SMTP server
mailman.SmtpHost = "smtp.gmail.com"
mailman.SmtpPort = 465
mailman.SmtpSsl = 1

'  Set the SMTP login/password.
mailman.SmtpUsername = "chilkat.support"
mailman.SmtpPassword = "myPassword"

Dim email As New ChilkatEmail2
email.Subject = "This is a test" & a
email.Body = "This is a test" & a
email.From = "Chilkat Support <chilkat.support@gmail.com>"
email.AddTo "Chilkat","support@chilkatsoft.com"

success = mailman.SendEmail(email)
If (success <> 1) Then
    MsgBox mailman.LastErrorText
    Exit Sub
End If
**next a**
link

answered Apr 30 '13 at 10:59

Ron's gravatar image

Ron
1223

edited Apr 30 '13 at 11:01

There is no limit as to how long the connection is left open. Chilkat doesn't close it after any period of time.

If the connection is lost, the next call to SendEmail should automatically reconnect.

One more thing -- make sure to change the recipient for each loop iteration, otherwise the result will not be good...

link

answered Apr 30 '13 at 11:57

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

The results I am getting are not what you are describing, below is a log file from a test I ran on an SMTP server on my server computer. I had a loop of 250 emails and as you can see from the log Chilkat is sending a "Quit" after every email.

My code uses the same Mailman object instance, it is exactly like the code I pasted earlier. I tried with the loop including the setting of the host,port, ssl , user and pass and with those values set before the loop and get the same results both ways.

Any ideas?

"SMTPD" 1536    8002    "2013-04-30 12:17:37.935"   "184.89.67.60"  "SENT: 220 smtp.mysite.com ESMTP"
"SMTPD" 1520    8002    "2013-04-30 12:17:37.982"   "184.89.67.60"  "RECEIVED: EHLO Office1"
"SMTPD" 1520    8002    "2013-04-30 12:17:37.982"   "184.89.67.60"  "SENT: 250-smtp.mysite.com[nl]250-SIZE 20480000[nl]250 AUTH LOGIN"
"SMTPD" 1556    8002    "2013-04-30 12:17:38.013"   "184.89.67.60"  "RECEIVED: AUTH LOGIN"
"SMTPD" 1556    8002    "2013-04-30 12:17:38.013"   "184.89.67.60"  "SENT: 334 VXNlcm5hbWU6"
"SMTPD" 1560    8002    "2013-04-30 12:17:38.044"   "184.89.67.60"  "RECEIVED: cm9uQHJ0b3Byby5jb20="
"SMTPD" 1560    8002    "2013-04-30 12:17:38.044"   "184.89.67.60"  "SENT: 334 UGFzc3dvcmQ6"
"SMTPD" 1532    8002    "2013-04-30 12:17:38.091"   "184.89.67.60"  "RECEIVED: ***"
"SMTPD" 1532    8002    "2013-04-30 12:17:38.091"   "184.89.67.60"  "SENT: 235 authenticated."
"SMTPD" 1536    8002    "2013-04-30 12:17:38.123"   "184.89.67.60"  "RECEIVED: MAIL FROM:<sales@mysite.com>"
"SMTPD" 1536    8002    "2013-04-30 12:17:38.138"   "184.89.67.60"  "SENT: 250 OK"
"SMTPD" 1552    8002    "2013-04-30 12:17:38.169"   "184.89.67.60"  "RECEIVED: RCPT TO:<me@mysite.com>"
"SMTPD" 1552    8002    "2013-04-30 12:17:38.169"   "184.89.67.60"  "SENT: 250 OK"
"SMTPD" 1512    8002    "2013-04-30 12:17:38.201"   "184.89.67.60"  "RECEIVED: RCPT TO:<me@mysite.com>"
"SMTPD" 1512    8002    "2013-04-30 12:17:38.201"   "184.89.67.60"  "SENT: 250 OK"
"SMTPD" 1568    8002    "2013-04-30 12:17:38.248"   "184.89.67.60"  "RECEIVED: DATA"
"SMTPD" 1568    8002    "2013-04-30 12:17:38.248"   "184.89.67.60"  "SENT: 354 OK, send."
"SMTPD" 1304    8002    "2013-04-30 12:17:38.326"   "184.89.67.60"  "SENT: 250 Queued (0.079 seconds)"
"SMTPD" 1528    8002    "2013-04-30 12:17:38.373"   "184.89.67.60"  "RECEIVED: QUIT"
"SMTPD" 1528    8002    "2013-04-30 12:17:38.373"   "184.89.67.60"  "SENT: 221 goodbye"
"SMTPD" 1536    8003    "2013-04-30 12:17:39.732"   "184.89.67.60"  "SENT: 220 smtp.mysite.com ESMTP"
"SMTPD" 1548    8003    "2013-04-30 12:17:39.763"   "184.89.67.60"  "RECEIVED: EHLO Office1"
"SMTPD" 1548    8003    "2013-04-30 12:17:39.763"   "184.89.67.60"  "SENT: 250-smtp.mysite.com[nl]250-SIZE 20480000[nl]250 AUTH LOGIN"
"SMTPD" 1540    8003    "2013-04-30 12:17:39.810"   "184.89.67.60"  "RECEIVED: AUTH LOGIN"
"SMTPD" 1540    8003    "2013-04-30 12:17:39.810"   "184.89.67.60"  "SENT: 334 VXNlcm5hbWU6"
"SMTPD" 1568    8003    "2013-04-30 12:17:39.841"   "184.89.67.60"  "RECEIVED: cm9uQHJ0b3Byby5jb20="
"SMTPD" 1568    8003    "2013-04-30 12:17:39.841"   "184.89.67.60"  "SENT: 334 UGFzc3dvcmQ6"
"SMTPD" 1544    8003    "2013-04-30 12:17:39.888"   "184.89.67.60"  "RECEIVED: ***"
"SMTPD" 1544    8003    "2013-04-30 12:17:39.888"   "184.89.67.60"  "SENT: 235 authenticated."
"SMTPD" 1528    8003    "2013-04-30 12:17:39.919"   "184.89.67.60"  "RECEIVED: MAIL FROM:<sales@mysite.com>"
"SMTPD" 1528    8003    "2013-04-30 12:17:39.919"   "184.89.67.60"  "SENT: 250 OK"
"SMTPD" 1552    8003    "2013-04-30 12:17:39.966"   "184.89.67.60"  "RECEIVED: RCPT TO:<me@mysite.com>"
"SMTPD" 1552    8003    "2013-04-30 12:17:39.966"   "184.89.67.60"  "SENT: 250 OK"
"SMTPD" 1520    8003    "2013-04-30 12:17:39.998"   "184.89.67.60"  "RECEIVED: RCPT TO:<me@mysite.com>"
"SMTPD" 1520    8003    "2013-04-30 12:17:39.998"   "184.89.67.60"  "SENT: 250 OK"
"SMTPD" 1544    8003    "2013-04-30 12:17:40.044"   "184.89.67.60"  "RECEIVED: DATA"
"SMTPD" 1544    8003    "2013-04-30 12:17:40.044"   "184.89.67.60"  "SENT: 354 OK, send."
"SMTPD" 1304    8003    "2013-04-30 12:17:40.123"   "184.89.67.60"  "SENT: 250 Queued (0.078 seconds)"
"SMTPD" 1520    8003    "2013-04-30 12:17:40.169"   "184.89.67.60"  "RECEIVED: QUIT"
"SMTPD" 1520    8003    "2013-04-30 12:17:40.169"   "184.89.67.60"  "SENT: 221 goodbye"
link

answered Apr 30 '13 at 12:26

Ron's gravatar image

Ron
1223

Maybe you are using an old version?

link

answered Apr 30 '13 at 13:06

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

And there is the "Aha" moment... I haven't downloaded any updates in a while. Chilkat stuff is so rock solid I never think to do updates occasionally. I'll use the latest version and see if it changes the behavior... which I'm sure it will. Thanks for the help, sorry to waste your time.

(Apr 30 '13 at 13:19) Ron

That was it, the new version works exactly as expected, thank you!

(Apr 30 '13 at 13:37) Ron

How does Ron get the log of results that he uses to figure out that the results weren't right? How do I create a log file while sending multiple emails with one connection like Ron?

Thanks

link

answered May 07 '15 at 15:10

ChrisM's gravatar image

ChrisM
1

I'd put money on that log file being Ron's SMTP server, not something that he has created in code or generated from Chilkat.

Dan

(May 08 '15 at 02:23) AgeofStrife
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×184
×96

Asked: Apr 30 '13 at 10:34

Seen: 2,975 times

Last updated: May 08 '15 at 02:23

powered by OSQA