I have like 28,000 email on an excel sheet, which is the best tool that i can use to send a mass mail effectively.
Most of the wordpress plugins that i have tried seems not able to send this huge number.
refactor to match your requirements cc @Mkulima , and happy coding
/*you will need to import below two namespaces*/
using System.Net;
using System.Net.Mail;
namespace Emails
{
internal class email_sender()
{
void send(list<string> email_addresses)
{
MailAddress[] lst_emails = validate_addresses(email_addresses); // check that all addresses meet the uri standard
if(lst_emails.Length > 0 ) {
if( ! send_email(lst_emails ) )
//add something here for dealing with failure
else
//add something here for dealing with success
}
}
bool send_email(MailAddress[] EmailAdresses)
{
bool bResult = false;
try
{
var senders_email = new MailAddress("add senders email address here", "OPTIONAL SENDERS NAME GOES HERE");
//create am SMTP object
var smtp = new SmtpClient
{
Host = smtp_host goes here,
Port = smtp_port goes here,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("senders email address", "senders email password")
};
//create a mail message object
using (MailMessage mMessage = new MailMessage(senders_email, EmailAdresses[0])) // user address 0 as TO ADJUST TO MATCH YOUR REQUIREMENTS
{
/* add the rest as cc or bcc but remember to factor in the provider specific limits on number of cc and bcc recipients*/
for (int i = 1; i < EmailAdresses.Length; i++) mMessage.CC.Add(EmailAdresses[i]);
mMessage.Subject = "SUBJECT GOES HERE";
mMessage.ReplyTo = new MailAddress(senders_email.Address); // this is deprecated
mMessage.IsBodyHtml = true;
mMessage.Body = "BODY GOES HERE";
smtp.Send(mMessage);
bResult = true;
}
}
catch (Exception ex)
{
//DO SOMETHING WITH THE ERROR MESSAGE
}
return bResult;
}
MailAddress[] validate_addresses( List<string> _addresses)
{
MailAddress[] result = new MailAddress[0];
for (int i = 0; i < _addresses.Count; i++)
{
try
{
MailAddress _emallAddress = new MailAddress(_addresses[i]);
if (_emallAddress != null)
{
Array.Resize(ref result, result.Length + 1);
result[result.Length - 1] = _emallAddress;
}
}
catch { }
}
return result;
}
}
}
Right. But rarely used… because most PHP sites are hosted on a Linux distro. And in case you want to deploy ASP.NET scripts then you’ll generally have to host on a Windows Server.
I would have suggested a 3rd party mailing service that has support for queing and all that. 20,000 mails at a go na maybe site iko Kenyaweb ataangusha server ya yenyewe.
Ama awekewe cron job that can send the mails in the background pole pole.
been there, seen it all, i hate the easy way out, once re-compiled some open source piece of shit, 3 weeks later all my alarms went off ,DOS attack, since then… never ever