Creating a Mailing list with swift Mailer and Symfony1.0
By Herve le turdu

The Php mailer of Symfony 1.0 doesn’t handle important mailing list. No buffer, no Smtp server. The best is to use Swift mailer with a batch script processing in background…

Here is how to send an HTML email with the Swift Library with symfony 1.0:

Copy the autoload.yml in: myapps/config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
try
{
  // Set up the Smtp connection using your google account
  $connection   = new Swift_Connection_SMTP('smtp.gmail.com', 465,
                                  Swift_Connection_SMTP::ENC_SSL);
  $connection->setUsername('h.le.turdu@gmail.com' );
  $connection->setPassword('xxx' );
  // Create the mailer and message objects
  $mailer = new Swift(new Swift_Connection_NativeMail());
  $message = new Swift_Message
  ('Mail\'s subject', $mailBody, 'text/html');
 
  // Send
  $mailer->send($message, $mailTo, $mailFrom);
  $mailer->disconnect();
}
catch (Exception $e)
{
  $mailer->disconnect();
  // handle errors here
}

and in a batch file

1
2
3
4
5
$swift = new Swift(new Swift_Connection_SMTP(smtp_server_address));
$recipients = new Swift_RecipientList();
$message = new Swift_Message($email_subject, $email_body);
foreach ($addresses as $address) $recipients->addTo($address);
$swiftbatchSend($message, $recipients, $from_email_address);

Get the best prices on the web



RECENTLY BLOGGED ABT

TWEETS

  • My twitter:

Test of NS:

I will try to insert different elements into it:

Broken TWiTTs :(

  •  

AUTHOR

  • Hervé Le TurduMy name is Herve Le Turdu.
    I am a 32 years old french* man with an inquiring mind and an enthusiastic personality. Get to know me better !

    *Pardon my English tainted with a strong accent and of many mistakes

Projects & Work

LINKS - BeCause they deserve it!

I Love SEOgadget ----------------------------------------------------
Testing stuff:
http://leturdu.com/2009/02/creating-a-mailing-list-with-swift-and-symfony/

Test 1 // show post ID: 85

Test 2 // show category page: Web development