I have problem in sending message in contact us form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RomeoX
    New Member
    • Jan 2010
    • 25

    I have problem in sending message in contact us form

    Hi there,

    I have created a free website at Xtreemhost site. They are saying that they support Send email in the free hosting. Anyway I tried to set a page "Contact Us" and I want the visitor when he send me a message so it will be sent to my Gmail with his name as well. I tried a lot of code when I did search in Google but nothing is working, I don't know where is the problem. The code seems okay and it says that "meesage has been sent" but when I go to my email Gmail I don't find any email from my website.

    I hope someone can really help me to fix this problem.

    Code:
    <?php 
    if ($_POST["email"]<>'') { 
    	$ToEmail = 'wazxcv@gmail.com'; 
    	$EmailSubject = 'Site contact form '; 
    	$mailheader = "From: ".$_POST["email"]."\r\n"; 
    	$mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
    	$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    	$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
    	$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
    	$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>"; 
    	mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
    ?> 
    Your message was sent
    <?php 
    } else { 
    ?> 
    <html><body>
    <form action="new.php" method="post">
    <table width="400" border="0" cellspacing="2" cellpadding="0">
    <tr>
    <td width="29%" class="bodytext">Your name:</td>
    <td width="71%"><input name="name" type="text" id="name" size="32"></td>
    </tr>
    <tr>
    <td class="bodytext">Email address:</td>
    <td><input name="email" type="text" id="email" size="32"></td>
    </tr>
    <tr>
    <td class="bodytext">Comment:</td>
    <td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
    </tr>
    <tr>
    <td class="bodytext">&nbsp;</td>
    <td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
    </tr>
    </table>
    </form> </body></html>
    <?php 
    }; 
    ?>

    Another example I used as well but didn't work well with me. I installed phpmailer inside a folder.

    Code:
    <?php  
     
    require("class.phpmailer.php"); // path to the PHPMailer class
     
    $mail = new PHPMailer();  
     
    $mail->IsSMTP();  // telling the class to use SMTP
    $mail->Mailer = "smtp";
    $mail->Host = "ssl://smtp.gmail.com";
    $mail->Port = 465;
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->Username = "yourusername@gmail.com"; // SMTP username
    $mail->Password = "yourpassword"; // SMTP password 
     
    $mail->From     = "email address sender";
    $mail->AddAddress("email address receiver");  
     
    $mail->Subject  = "First PHPMailer Message";
    $mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
    $mail->WordWrap = 50;  
     
    if(!$mail->Send()) {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail->ErrorInfo;
    } else {
    echo 'Message has been sent.';
    }
    ?>

    Actually I checked the Spamer folder doesn't have any email, so the problem is that I can't get any email from my website.

    I found here some website is talking about my problem is well but actually I tried to implement what are they saying but I couldn't solve my problem

    http://xtreemhost.com/2010/04/11/how-to-send-e-mails-via-smtp-with-phpmailer-and-gmail/#codesyntax_1

    http://www.google.com/support/forum/p/Google%20Apps/thread?tid=2def 4c3c8f1f7397&hl =en

    Please give me your hand in fixing this problem I did a lot of search on google before asking here. Thanks in advanced.
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    You're printing your message has been sent no matter what. Shouldn't you only send that message when mail() function returns true?

    You're not even capturing the output of the mail() function.

    see php.net/mail.

    I'm guessing it will return false. You need a working smtp server (mail server) and authentication to use it to successfully "send" an email.

    Receiving an email is a whole set of different problems. gmail might choose to block your domain completely if it looks suspicious or Domain/MX and SPF settings are out of wack.

    Dan

    Comment

    • RomeoX
      New Member
      • Jan 2010
      • 25

      #3
      Thanks for replying to me. Actually my webhost telling that they totally support SMTP for free, but they told me to Request a ticket if I need them to fix my code but they charge tooooooo much. They told me it's code problem, so what should I do now. Please I'm waiting anyone to help. Thanks

      Comment

      Working...