phpmail example
Example 1: php mail
<?php
$to = $_POST['email'];
$subject = "Email Subject";
$message = 'Dear '.$_POST['name'].',<br>';
$message .= "We welcome you to be part of family<br><br>";
$message .= "Regards,<br>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
mail($to,$subject,$message,$headers);
?>
Example 2: phpmailer example php
<?php
require_once('class.phpmailer.php');
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->SMTPDebug = 1;
$mailer->Port = 587;
$mailer->Host = 'smtplw.com.br';
$mailer->SMTPAuth = true;
$mailer->Username = 'smtplocaweb';
$mailer->Password = 'Gwb9etA323';
$mailer->FromName = 'Bart S. Locaweb';
$mailer->From = '[email protected]';
a mesma caixa postal configurada no remetente do SMTP
$mailer->AddAddress('[email protected]','Nome do
destinatário');
$mailer->Subject = 'Teste enviado através do PHP Mailer
SMTPLW';
$mailer->Body = 'Este é um teste realizado com o PHP Mailer
SMTPLW';
if(!$mailer->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $mailer->ErrorInfo; exit; }
print "E-mail enviado!"
?>