Return to Snippet

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


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

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

   //Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 25)
  ->setUsername('[email protected]')
  ->setPassword('password')
  ;

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

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

//Mail
$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
PHP