Skip to content

Instantly share code, notes, and snippets.

@rat
Created November 25, 2013 14:34
Show Gist options
  • Save rat/7642083 to your computer and use it in GitHub Desktop.
Save rat/7642083 to your computer and use it in GitHub Desktop.
<?php
$subject = 'Assunto';
$from = 'fulano@gmail.com';
$to = 'ciclano@hotmail.com';
$bcc = null; // Esconder endereços de e-mails.
$cc = null; // Qualquer destinatário pode ver os endereços de e-mail especificados nos campos To e Cc.
$message = 'Corpo da mensagem';
$headers = sprintf( 'Date: %s%s', date( "D, d M Y H:i:s O" ), PHP_EOL );
$headers .= sprintf( 'Return-Path: %s%s', $from, PHP_EOL );
$headers .= sprintf( 'To: %s%s', $to, PHP_EOL );
$headers .= sprintf( 'Cc: %s%s', $cc, PHP_EOL );
$headers .= sprintf( 'Bcc: %s%s', $bcc, PHP_EOL );
$headers .= sprintf( 'From: %s%s', $from, PHP_EOL );
$headers .= sprintf( 'Reply-To: %s%s', $from, PHP_EOL );
$headers .= sprintf( 'Message-ID: <%s@%s>%s', md5( uniqid( rand( ), true ) ), $_SERVER[ 'HTTP_HOST' ], PHP_EOL );
$headers .= sprintf( 'X-Priority: %d%s', 3, PHP_EOL );
$headers .= sprintf( 'X-Mailer: PHP/%s%s', phpversion( ), PHP_EOL );
$headers .= sprintf( 'Disposition-Notification-To: %s%s', $from, PHP_EOL );
$headers .= sprintf( 'MIME-Version: 1.0%s', PHP_EOL );
$headers .= sprintf( 'Content-Transfer-Encoding: 8bit%s', PHP_EOL );
$headers .= sprintf( 'Content-Type: text/html; charset="iso-8859-1"%s', PHP_EOL );
mail( null, $subject, $message, $headers );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment