Return to Snippet

Revision: 34346
at October 21, 2010 09:03 by juanchifc

Initial Code
   require_once 'lib/swift_required.php';
   include "conexion.php";

   $correo = $_POST['correo']; //Mail Receiver

   //Create the Transport
$transport = Swift_SmtpTransport::newInstance('', 25)
  ->setUsername('[email protected]')

You could alternatively use a different transport such as Sendmail or Mail:

$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');

$transport = Swift_MailTransport::newInstance();

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

//Create a message
$message = Swift_Message::newInstance('Banco de Ideas')
  ->setFrom('[email protected]')
  ->setTo($correo) // ->setTo('[email protected]')
  ->setBody('Your message...')
//Send the message
$result = $mailer->send($message);

You can alternatively use batchSend() to send the message

$result = $mailer->batchSend($message);


Initial URL

Initial Description
Script to send mails with Swift Mailer

Initial Title
Send mail with Swift Mailer

Initial Tags
php, mail

Initial Language