Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // please only use the fields thata re present in the html form itself for now we have listed all possible ones
- //// NEW CODE ////
- require '../mail/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- //$mail->SMTPDebug = 3; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.domain.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'username'; // SMTP username
- $mail->Password = 'password'; // SMTP password
- $mail->SMTPSecure = 'SSL'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 465; // TCP port to connect to
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- $mail->setFrom('hello@example.com', 'Name');
- $mail->addAddress('maher@domain.com', 'Location'); // Add a recipient // Name is optional
- $mail->addReplyTo('hello@example.com', 'Name');
- //$mail->addCC('cc@example.com');
- //$mail->addBCC('bcc@example.com');
- //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- $mail->Body = 'This is the HTML message body <b>in bold!</b>';
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- if(!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo 'Message has been sent';
- }
- //// OLD CODE ////
- $to = "maher@domain.com";
- if (isset($_POST)){
- $subject = "location system email";
- if ($_POST['fullname'] ! =''){
- $message = "Fullname: " . $_POST['fullname'];
- } else {
- $message = "First name: " . $_POST['fname'];
- $message = "Last name: " . $_POST['lname'];
- }
- $message .= "<br>Phone: " . $_POST['Phone'];
- $message .= "<br>Website: " . $_POST['website'];
- $message .= "<br>Email: " . $_POST['email'];
- $message .= "<br>Message: " . $_POST['message'];
- };
- $headers = "MIME-Version: 1.0" . "rn";
- $headers .= "Content-type: text/html; charset=utf-8" . "rn";
- $headers .= "From: " . $_POST['fullname'] . " <" . $_POST['email'] . ">". "rn";
- if(mail($to, $subject, $message, $headers) ) {
- echo "ok";
- } else {
- echo "error";
- }
Add Comment
Please, Sign In to add comment