require("/etc/php5/phpmailer/class.phpmailer.php");
//Creates a new mail
$mail = new PHPMailer();
//I need to set this since i use SMTP
$mail->IsSMTP();
//This is my SMTP host, i cannot send mails directly so i need to use my ISP's SMTP
$mail->Host = "smtp.bredband.net:25";
//And they doesn't use Authentication
$mail->SMTPAuth = false;
//This is the email from which the mail will be sent
$mail->From = "john.doe@example.com";
//If this is not set all mails will be sent from "Root User"
$mail->FromName = "John Doe";
//Where the mail is going, you can also do AddAddress(address, name)
$mail->AddAddress(nl2br($recipient));
//The mail should be sent as HTML which means you should do a nl2br()
$mail->IsHTML(true);
//The subject
$mail->Subject = $subject;
//The body
$mail->Body = nl2br($body);
//Send the mail, do stuff if true or false
if(!$mail->Send()){
header("Location: /contact.php?mail=failed");
}
else{
header("Location: /contact.php?mail=success");
}