Im writing a tool c# (and System.Net.Mail) which will be sending around 4000 emails fornigtly.
Can i simply loop through a list of 4000 email addresses and send emails one at a time?
or will this cause any potential problems?
Is there a better way to do this?
Thanks
First of all you must have rDNS record that will map IP address back to domain name. Without it mail services like GMail will hold your e-mails for hours or even days. Furthermore you may become blacklisted after few dozens of letters. rDNS usually can be set using hoster's control panel or by support request.
Second, don't be tempted to use your ISP's or GMail's SMTP servers. You will quickly run out of daily quota. It is usually not allowed to send more than few dozens letters (50 for GMail AFAIK). So either send mail from your own server, or use a 3rd party service like auth smtp.
Such services are useful also if you're unable to set rDNS for some reason.
P.S. If the content of your letters is OK (i.e. they are not spam actually) and rDNS/SMTP are set correctly, you can send at any rate, without pauses.
Provided you don;t break any server limitations, such as memory or disk space, technically there is no issue. However you will run into problems with with ISP's and mail forwarders who may block your domains for spam - rightly or wrongly..
You could send the 4000 emails in one go, but you do run the risk of getting marked very quickly as a spammer.
Your best option is to 'burst send' so send maybe 100 straight away, in 10mins send another 100 etc.
If you do it this way your are less likely to be seen as a spammer.
Check that the machine sending the mails has a valid PTR record - i.e., if you're sending from www.example.com with IP 1.2.3.4, that a PTR query on 1.2.3.4 will return www.example.com; I'd look into SPF and DKIM, too.
Some e-mail hosts have an incoming rate limit (e.g. Hotmail used that in the past) - "if you are sending us more than x emails/minute, you get a higher spam score". I had a script to "stir the queue", so that the per-minute rate to a single server was lowered.
Also, check this - it has plenty of good advice on e-mail content, but that's slightly off-topic.
In addition to what has been mentioned above, be sure to set up adequate logging.
I.e. you should log sent emails so if you need re-send emails you can be sure not to send duplicates.
Also, you can set up an app to log bounced emails and use this to remove addresses etc.
You can of course write your own software or purchase some.
http://www.quiksoft.com/bouncebuster/
Related
Is there a way to fetch only the new emails from the mail server (e.g. when you store the fetched emails locally) instead of fetching all of them?
I guess I could fetch emails in bunches of 5 and compare, for example, the hash of the last email (or its Uid from Pop3Client.GetMessageUid()) to the hash of the fetched emails, but I am not sure if this is the best and most reliable way. I think this will be a waste of bandwidth or bombarding the server with multiple requests.
Does the protocol allow specifying a point in time (using date, last email hash or whatever), after which it should return the emails?
Currently, I am using OpenPop.NET's OpenPop.Pop3.Pop3Client.
EDIT
I have found an example here:
http://hpop.sourceforge.net/exampleDownloadUnread.php
Although it doesn't suit my needs 100% (because it fetched ALL UIDs which may be too many) it is a good starting point.
Basically, what I want to do is what this IMAP sample does by comparing UIDs:
http://www.limilabs.com/blog/get-new-emails-using-imap
EDIT 2
I have found this similar question, but it also suggest the approach that retrieves ALL UIDs:
How to retrieve only new emails using POP3 protocol
You'll need to download all of the UIDs no matter what you do because you'll need to compare them to what you've already downloaded (in some sort of UID log) as well as having the UIDs of the new messages so that you can log them to compare against the next time you connect.
It should be noted, however, that not all POP3 servers support the UIDL command (it is an extension, after all), so if your code is meant to be used with a variety of POP3 servers, it will have to deal with that. How you deal with it is up to you, but I believe that my approach in the past has been to md5sum a collection of headers (although not all of them, because some POP3 servers might add or modify headers such as X-Status or Status or some custom header). You can probably get away with just hashing the Received headers.
I have a site I'm building and have a DB backup running on it several times a day.
Every successful backup is sent to my mail (and directed by a rule to a folder since there are many backups..) and every failure is also sent to me (not directed by a rule).
I'm afraid that the task will stop running from some reason and I will not know (no alerts arriving but how can I notice it in the blur of mails).
Is there a SW or process that alerts me when a mail was not received during a specific time?
The reason I'm asking here is that I want to develop this kind of thing (if does not exist).
Thanks
You cannot know, unless you create something for yourself. E.g. a rule to auto-reply the received message (at receiver's mailbox). Your program (that sent the e-mail) should check his own mailbox within x seconds for the reply after sending.
Normally it is just a send and goodbye system, unless the e-mail box is full, unreachable, etc.
I am working on a site and it has to have a newsletter sending functionality. A couple of weeks ago I posted a question on stackoverflow, and the good people suggested that I do a console app which I call from the site and it sends the mails. I did this, and it works locally, but I wasn't able to get it working on the server (security issue). Been trying to make this work for the past 3 days. So then, I decidet to try and change how the email is sent.
To make a long story short, now I split all the emails in "groups" of 50, and then make a new MailMessage object, and mailMessage.To.add(sample#sample.com) emails to it. Then I send it 50 by 50.
It works for now, but my question is, how "BAD" is this solution? I tryed adding the emails to bcc, but for some reason (for me) this works only locally ( !?! ).
And one more thing which I couldn't find on line, what is the maximum number of mails I can add to the MailMessage object?
Thank you for your time!
Andrej
its very bad since each user which receives your newsletter will have access to the 49 other contacts (where do i sign up?)
If you are having problems with multiple BCC's, contact you SMTP host.
Did you try sending each separately? if it is taking to long to send, you can build a multi-threaded solution which will help.
The correct way is to send each one his mail and you create a queue in memory on in database for store mail before send.
Remember send all emails in 1 time if you use public smtp server is bad thing, you can be banned for that server,this means you must schedule such as 1000 mail at time or less.
i have wrote this years ago if you need i can post same code
I've been following this site with a lot of admiration especially on how questions are professionally answered so I decided to be fully involved.
Please, I need urgent help on a project that I have been working on for a long time but it's almost stalled now just because of a critical issue.
An aspect of the program automates email sending to clients using the free email server systems. Due to the high frequency of email sending, I observed that the email server we're sending to drops larger parts of the emails sent out and literally blocks delivery of major emails to the recipients.
I have tried to reduce the rate of sending email out but to no avail. My fear now is my IP address might have been blocked or may be blocked soon if this continue. The program is not spamming but have to be developed in order to contact a large database of recipients at a goal within short time - like about 1000 or more recipients.
I am using Webbrowser control in C# to automate the process of logging in to the mail server and sending the email out.
Now, what I want is a sample code to use publicly available web proxy servers for each email sent out such that the source IP address appears dynamic and different to the target email server each time a message is sent out to it.
I mean, I want to dynamically get and use free public proxy servers with the Webbrowser control to send out the emails. In this way I believe the email servers would not be able to reject the emails base on the IP address source. I want to know how to dynamically get literally one web proxy server for each email sent, if possible each time.
This project is very critical and this feature is a determinant. I have googled endlessly without any straight forward solution to this issue. I would, therefore, appreciate any useful help, sample codes or resources that could help me to solve this nagging problem once and for all.
Thank you!
Your problem is "free email server systems": they consider you a spammer, and the idea you suggest (spoofing IPs) will, if detected, ruin your reputation.
If you explain what you are trying to accomplish, perhaps someone here can offer a better design.
Are you trying to give people with free email accounts (like Hotmail) bulk-emailing capabilities?
First of all (if I understood your answer right), you don't have to use WebBrowser control - you can use specified .NET solutions that allows you to efficiently sending mails:
MailMessage msg = new MailMessage("from", "to", "subject", "body text");
SmtpClient client = new SmtpClient("smtp server");
System.Net.NetworkCredential cred = new System.Net.NetworkCredential("user", "password");
client.UseDefaultCredentials = false;
client.Credentials = cred;
Client.Send(msg);
Unfortunately, if you want to send e-mails to many recipients and you want to be sure, that these messages reach the recipients - you have to do it using your own e-mail server or do it by purchase the service on a paid e-mail servers - then they will not treat you as a spammer.
But if you anyway want to send e-mails by rotation proxy servers or similar sollution - you can define your proxy:
SmtpClient client = new SmtpClient("my.proxy_server.com", 8080);
First you have to collect any list of available proxy servers which allows you to do it in reasonable time (servers switching can significantly increase total process time because conection time can be different for each proxy server)
Proxy servers list ordered by access time:
http://www.publicproxyservers.com/proxy/list_avr_time1.html
I use C# to send email using System.Net.Mail.
But How can I know whether the email has been sent successfully or fail?
Not a direct answer of course, but here is a great article from Coding Horror about sending emails through code, which addresses your question.
The simple answer is that if it's a detectable failure then SmtpClient.Send will throw an SmtpFailedRecipientsException (it will throw an SmtpException if there is a connection problem).
The long answer is that, for many reasons, you won't necessarily get an exception. This can be because your SMTP server is buffering the sends (or if you have it set to local iis or local directory), or simply because the SMTP server does not support returning those error codes.
Most advertising mailing systems track bouncebacks by setting a valid "from address" and monitoring the inbox for that account. Even that, however, is not foolproof (out of office messages, for example).
I would stick to catching exceptions and leaving the others. If you're not sure if emails are valid, maybe you should send users a code to have them validate their email address.
Considering Emails are fire-and-forget, this can be quite hard. Unless you get an exception, denoting a client-server communication issue due to wrong credentials etc, you have no means of knowing if a mail was sucessfully send (meaning: arrived at the addressee).
I've personally never come across an answer to this as there's not really a way you can grantee mail leaving your location is'nt going to get thrown away as soon as it leaves you. You could maybe try and check the sending mailbox for an NDR (none delivery report) but your not always granted to get one
If you mean sent successfully then as other posters say, if it cannot be sent then you will get an exception. If you actually mean recieved succesfully then that is an entirely different matter. SMTP simply does not have a mechanism to find out if the message has been recieved by the recipient, sometimes you will get an ndr if a server can't deliver other times you won't. You could try and do what spammers do and that is to put some kind of image link in your html email body with a unique identifier in the query string. That would allow you to link someone hitting the image url with the email. However that would only tell you the email had been read if the url was hit, it would not tell you that the email hadn't been recieved becuase the recipient might simply not have allowed images to be displayed in their email client.