views:

492

answers:

2

I was trying to find an easier way to send e-mails to all my clients using our database (MySQL). I wanted to see if there is a way that it can select all the e-mails of my clients and I can add message, Subject and send it to all of my clients from my website rather than copying each of the mail.

Is there a way to integrate SMTP to do this? either using PHP or javascript.

Thanks.

+3  A: 

Yes, there are about 5,247 ways. See these:

Those are all good (and not the only ones). It is up to you to pick the one that best suits your purpose, there is no "single best" library.

karim79
Those are all good - I like PHPMailer the best, especially the way it interfaces with GMail
Jason
A: 

I use SwiftMailer .. it works wonders for me.

*  Send emails using SMTP, sendmail, postfix or a custom Transport implementation of your own
* Support servers that require username & password and/or encryption
* Protect from header injection attacks without stripping request data content
* Send MIME compliant HTML/multipart emails
* Use event-driven plugins to customize the library
* Handle large attachments and inline/embedded images with low memory use



require_once 'lib/swift_required.php';

//Create the Transport
$transport = Swift_SmtpTransport::newInstance('localhost', 25);

//Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);

//Create a message
$message = Swift_Message::newInstance('Wonderful Subject')
  ->setFrom(array('[email protected]' => 'John Doe'))
  ->setTo(array('[email protected]', '[email protected]' => 'A name'))
  ->setBody('Here is the message itself')
  ;

//Send the message
$numSent = $mailer->batchSend($message);

printf("Sent %d messages\n", $numSent);

/* Note that often that only the boolean equivalent of the
   return value is of concern (zero indicates FALSE)

if ($mailer->batchSend($message))
{
  echo "Sent\n";
}
else
{
  echo "Failed\n";
}

read more here .. http://swiftmailer.org/docs/batchsend-method

Wbdvlpr