en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en de en en en en nl en en en en en es en es en es en en en de en de en en en en en nl en en en en en en en en de en en en en nl en en en en de en en en en en en en en nl en en en en en en en en en en en en en nl en en en en en en en en en fr en da en en en en en en en nl en en en en en en en en en en es en en en en en en it en en en en en en en nl vi en en en en en en en en en en en en en de en en en en nl en en en en en en en de en en en en en en en en nl fr en en en en en en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in Programming the Internet only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Sending multiple mails with unique attachments
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
I am using PB's downloadable MAILFILE.BAS as a model for my program. It will need to send (currently) 11 e-mails in a once-daily batch. Each mail will have about 2K of body text and a .pdf which will be about 25K. Each recipient will get a different .pdf, but the body text will be the same for everyone.
I can see three approaches I can take with this.
Make a big array and MIMEify the .pdf's in advance. Connect to the SMTP server and iterate through the PDF array, sending each mail one at a time until done.
Connect to the SMTP server and MIMEify each .pdf on the fly while I iterate through the recipient list. Disconnect after all messages sent.
Prepare one message then connect to the SMTP server. Send the message and disconnect. Lather, rinse, repeat.
What is the best way to handle the situation?
Last edited by Erich Schulman; 18 Sep 2008, 02:07 PM. Reason: Expand B) details
Join Date: Feb 2000
18 Sep 2008, 03:42 PM
What is the best way to handle the situation?
Define "best". Better yet, just flip a coin, it won't really matter which side or edge it lands on.
There *could* be a more "acceptable" approach depending on your email server, but I personally wouldn't bother wasting any time thinking about that. I'd suggest you pick a method that is easiest for you and do it.
Software makes Hardware Happen
Join Date: Aug 2001
18 Sep 2008, 10:38 PM
I don't know whether net admins generally prefer you hit the server once rather than 11 times, or if they don't care. I want to be respectful of that.
http://www.freesoft.org/CIE/RFC/1123/109.htm suggests I won't have timeouts if I generate the MIME on the fly. But if sending an unbroken stream is better, then I want to do that.
Join Date: Feb 2000
19 Sep 2008, 12:01 AM
I don't know whether net admins generally prefer you hit the server once rather than 11 times, or if they don't care
Pick 10 admins, chances are you'll get 5 on one side and 5 on the other.
Like I said, I don't really think it makes any difference one way or the other.
Software makes Hardware Happen
Join Date: Aug 1998
19 Sep 2008, 07:33 AM
Just for style points - well, really for restartability...
I like the idea of connect, send, disconnect one by one.
That way if something bad happens somewhere along the way, you know exactly how far you you got.... i.e., "Message 4 OK,,,  ". You know you need to re-send #5 through #10, but 1 through 4 went OK. You probably don't want to resend all since the guys who got 1-4 will be wondering why you sent them again.
Other than that, its six-five and pick'em
Port Washington WI USA
Join Date: Oct 2007
21 Sep 2008, 04:41 PM
Other than Mike's point about error trapping...
Since you're sending essentially different emails, if you were doing that in any other mail client you would:
a) create an email
b) attach the file
c) repeat a-b until done
d) connect to the server
g) repeat d-f until done
This avoids all sorts of spam traps on the server or on the recipient (if they use something like aol where suddenly 11 emails show up from the same source all sent at the same time)
Because the connect-disconnect creates different time stamps. Add a random 3-5 second delay between messages and it's even better.
Phone: 480 - 273 - 8798
Join Date: Aug 2006
24 Sep 2008, 07:38 PM
Why not check if you are online?
(or maybe VISTA breaks the api...I do not know)
The other side is, do the people you want to send some sort of update to, actually WANNNNT the update???
On top of everything else, several ISP's are hinting at a cap of what is downloaded, do you really want to push something over that cap just to do a daily update???
probably mute in this situation...but remember, this situation could EASILY be turned to the "Dark Side of the FORCE"
Engineer's Motto: If it aint broke take it apart and fix it
"If at 1st you don't succeed... call it version 1.0"
"Half of Programming is coding"....."The other 90% is DEBUGGING"
"Document my code????" .... "WHYYY??? do you think they call it CODE? "
Join Date: Aug 2001
25 Sep 2008, 08:36 AM
The method I implemented is sending one at a time with a random pause between each. I have the delay right after the "Preparing to send  ..." so from the end user's perspective it appears to be processing time.
Why not check if you are online?
I probably should for completeness, but since it is being sent from a server we can assume being online.
The other side is, do the people you want to send some sort of update to, actually WANNNNT the update???
They have to get it. Our customer is a corporate HQ and the mails are going to each franchisee. The reports are customized for what each needs (the stores are not all alike).
Join Date: Mar 2002
3 Oct 2008, 02:00 PM
Best way to send multiple emails using smtp
For what it's worth:
I've been working on reliably sending multiple emails via smtp using auth login and a standard domain user level username and password. After sending each email using tcp statements and closing the connection I found I avoided connection errors by opening each tcp connection with a different file number. I start at 50 and went up to 80 and then reset to 50. Doing it this way allowed me to send 30 emails with pdf attachments to my gmail account in about 20 seconds. They arrived at my gmail account out of order somewhat but there were no errors.
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 07:06 PM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.