Sending Mass Email Using PHP

Sending mass email using PHP

First off, using the mail() function that comes with PHP is not an optimal solution. It is easily marked as spammed, and you need to set up header to ensure that you are sending HTML emails correctly. As for whether the code snippet will work, it would, but I doubt you will get HTML code inside it correctly without specifying extra headers

I'll suggest you take a look at SwiftMailer, which has HTML support, support for different mime types and SMTP authentication (which is less likely to mark your mail as spam).

How to send mass emails through php

Role of MTA:

  1. receives email from the client's MUA
  2. passes email to the MDA for final delivery
  3. uses SMTP to route email between servers

See more: http://en.wikipedia.org/wiki/Message_transfer_agent

See this links for sending multiple emails:

  1. Sending mass email using PHP
  2. Sending bulk email in PHP

Update:

A message transfer agent(MTA) receives mail from either another MTA, a mail submission agent (MSA), or a mail user agent (MUA). The transmission details are specified by the Simple Mail Transfer Protocol (SMTP). When a recipient mailbox of a message is not hosted locally, the message is relayed, that is, forwarded to another MTA. Every time an MTA receives an email message, it adds a Received trace header field to the top of the header of the message, thereby building a sequential record of MTAs handling the message. The process of choosing a target MTA for the next hop is also described in SMTP, but can usually be overridden by configuring the MTA software with specific routes.

A MTA works in the background, while the user usually interacts directly with a mail user agent. One may distinguish initial submission as first passing through an MSA – port 587 is used for communication between an MUA and an MSA while port 25 is used for communication between MTAs, or from an MSA to an MTA; this distinction is first made in RFC 2476.

How to Send Bulk Emails via Phpmailer

This question is indeed too broad, so you're only going to get vague answers.

You should at least look at the mailing list example provided with PHPMailer, as that deals with the basics. PHPMailer is perfectly capable of high speeds - I have no trouble getting ~250 messages per second using it.

It helps to have a very cosy relationship with your mail server too - many open source ones are either not up to the job or are hard to configure, but 4,000/hour is a tiny amount in the scheme of things and default configs can work.

You need to have absolutely solid SPF, DKIM and DMARC configs, plus hypersensitive bounce handling (remailing a previously bouncing address on yahoo can get you blocked for ages).

Technical steps aside, it will take you a while to build up a sending reputation no matter what you do, and the behaviour of many large ISPs is pretty bad. For example I have a community site with several thousand members on hotmail, and occasionally one of them reports a notification as spam (it's all just forum traffic, no mailshots) - this results in the entire site being blacklisted and spamboxed for every hotmail member for about 2 months. Really not very clever or helpful.

Sending Bulk emails through phpmailer

This is happening because you're not clearing the to addresses each time around your loop - notice the method is called addAddress, not setAddress, and it does what that suggests. You need to call $mail->clearAddresses(); at the end of your loop to reset it. You're doing things mostly right otherwise, but there are a few things you can do to improve efficiency, mainly using keep alive and setting all the properties that are common to all messages before your loop.

You can see all this working in the mailing list example provided with PHPMailer.

PHPMailer: Mass Emails - Send all variable messages at once, instead of individually

There's an example of how to send to a list from a database efficiently in the examples bundled with PHPMailer. There's nothing inherently likely to get you blacklisted by using PHPMailer for sending large volumes, but you do need to tread carefully. Mandrill isn't magic - it's as vulnerable as anything else to being blocked if you send spam through it.

If you want to send 50 simultaneously from PHP, fire up multiple processes with the pcntl extension, but it won't actually help you very much as you'll be increasing overhead enormously. You can set SMTPKeepAlive = true in PHPMailer which will reduce overhead a lot (it avoids making a new connection for every message), but it still won't send simultaneous messages - nothing will. There isn't an option in SMTP to send multiple messages with different bodies simultaneously on the same connection.

Sending to a big list during a page load in a browser is very unreliable; use a cron script or background process to do your actual sending and just set it up through your web interface. One tip if you are waiting for a page load - call ignore_user_abort() early on so that it won't stop sending if your browser closes the connection - and beware the page refresh! If you want to send much faster, install a local mail server like postfix and use that to relay - it will be far faster and more reliable than sending directly.

PHP form send email to multiple recipients

This will work:

$email_to = "jhewitt@amleo.com,some@other.com,yet@another.net";


Related Topics



Leave a reply



Submit