Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['email'])) {
- // Require the Swift Mailer library
- require_once 'lib/swift_required.php';
- $transport = Swift_SmtpTransport::newInstance('mail.dominio.com.br', 25, 'tls' )
- ->setUsername('mail@dominio.com.br')
- ->setPassword('54321')
- ;
- $mailer = Swift_Mailer::newInstance($transport);
- // Creating the message text using fields sent through POST
- foreach ($_POST as $key => $value)
- $messageText .= ucfirst($key).": ".$value."\n\n";
- // You can change "A message from Pivot Template Form" to your own subject if you want.
- $message = Swift_Message::newInstance('Coronel David - Mensagem enviado pelo site')
- ->setFrom(array($_POST['email'] => $_POST['name']))
- ->setTo(array('contato@dominio.com.br' => 'Coronel David'))->setBody($messageText);
- // ^ ^
- // Your email address_/ Your name_/
- // Send the message or catch an error if it occurs.
- try{
- echo($mailer->send($message));
- }
- catch(Exception $e){
- echo($e->getMessage());
- }
- exit;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement