Tuesday, May 19, 2015

PHP Mailer SMTP Script for contact form on website that works on Godaddy

I have copied this PHPmailer script from my godaddy hosting account so it actually works well on godaddy deluxe hosting account which enables PHP execution.

3 files need to be uploaded into your godaddy hosting account where the mail script is going to reside. These are phpmailer libraries and can be found here:

https://github.com/PHPMailer/PHPMailer

PHPMailerAutoload.php
class.phpmailer.php
class.smtp.php

Only the PHPMailerAutoload.php is included in the script.

Change the hostname, username and password. You can copy these 3 from godaddy email configuration section in the hosting account.

smtp method of sending email for contact form sends the email from your website, using your website admin username. So the email never goes in to spam and is not ever considered suspicious. reply-to is the email the visitor enters on the contact form on your website, so that when you reply to the email it goes to customer not to the admin email of your website.

These 3 email addresses need to be your own:

admin@xxx.com  (email account on godaddy mail server for your website)
recipient@gmail.com  (whatever email address contact form will be send to)
$visitor_email (email address the user entered in contact form on your website)

<?php

    require './PHPMailerAutoload.php';

    if(isset($_POST['email']))

    {


    $name          = $_POST['name'];

    $phone         = $_POST['phone'];
    $visitor_email = $_POST['email'];
    $content       = $_POST['message'];



     if($visitor_email =="") {  //dont send email go back
           
              echo ("UNSUCCESSFUL:Please Enter Your Email");
         
         
             
             } else {    //try sending email


 
 $subject = "FROM Company";
 $bodytext .= $name . "<br>" . $phone . "<br>" . $visitor_email . "<br>" .  $content;
 


    $mail = new PHPMailer();
    $mail->IsHTML(true);
    $mail->isSMTP();
    $mail->SMTPDebug = 0;
 
    $mail->Host = "a2plcpnl0146.prod.iad2.secureserver.net";
    $mail->SMTPAuth = true;  
    $mail->Username = "admin@xxx.com";
    $mail->Password = "xxxxxxxx";
    $mail->port = 465;


$mail->addReplyTo($visitor_email);
$mail->setFrom('admin@xxx.com');



$mail->addAddress('recipient@gmail.com');
$mail->Subject = $subject;
$mail->Body = $bodytext;


 
 
   
 
              if($mail->Send()) {
              echo ("You message was sent SUCCESSFULLY");
             
             } else {
              echo ("Technical Problems:Your message was not sent");
             }

}
}
?>


12 comments:

  1. cooool my work is done just because of you Thankyou :)

    ReplyDelete
  2. not working with godaddy... showing some technical error

    ReplyDelete
  3. email sent but cant see actual message, but can see the Alt message

    ReplyDelete
  4. Hi! Use Port 587 in Godaddy Host, resolve the internal error

    ReplyDelete
  5. Really your content is so informative. So please share some more content ..
    How to fix GoDaddy emails going to the spam

    ReplyDelete
  6. Use this diet hack to drop 2 lb of fat in just 8 hours

    At least 160000 men and women are trying a easy and SECRET "liquids hack" to drop 1-2 lbs each and every night while they sleep.

    It's very easy and works with anybody.

    Here's how to do it yourself:

    1) Go grab a glass and fill it half glass

    2) Proceed to do this crazy HACK

    so you'll be 1-2 lbs lighter the next day!

    ReplyDelete
  7. Hi Clients!

    We have the fresh and valid USA ssn leads and dead fullz
    99% connectivity with quality
    *If you have any trust issue before any deal you may get few to test
    *Every leads are well checked and available 24 hours
    *Fully cooperate with clients

    *Format of Fullz/leads/profiles
    °First & last Name
    °SSN
    °DOB
    °(DRIVING LICENSE NUMBER)
    °ADDRESS
    (ZIP CODE,STATE,CITY)
    °PHONE NUMBER
    °EMAIL ADDRESS
    °REFERENCE DETAILS
    °BANK ACCOUNT DETAILS

    ****Contact Me****
    *ICQ :748957107
    *Telegram :@James307
    *Gmail :taimoorh944@gmail.com

    lead cost $2 for each
    Price can be negotiable if order in bulk

    *Contact soon!
    *Hope a long term deal
    *Thank You

    ReplyDelete
  8. I have read your article couple of times because your views are on my own for the most part. It is great content for every reader. godaddy workspace login

    ReplyDelete
  9. Situs Judi Slot Online - jtmhub.com
    Jammin' Jarslot88 adalah situs 서산 출장안마 judi online 파주 출장안마 terpercaya yang menyediakan permainan judi online 논산 출장마사지 seperti slot online, 광주광역 출장샵 judi bola, 과천 출장안마 slot88 & pragmatic play.

    ReplyDelete