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.
Expand|Select|Wrap|Line Numbers
- <?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"> </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.
Expand|Select|Wrap|Line Numbers
- <?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=2def4c3c8f1f7397&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.