开发者

Sending mail from a contact form. Simple but challenging! [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally开发者_开发百科 applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

I've set up a contact form in the Greet Us page in http://swedsb.com

When I submit the form, it says mail sent successfully. But I'm not getting the mail, checked the spam folder.

I've set a similar form at http://ibsolutions.in. It is working perfectly.

Been breaking my head for the past 4 hours. Here's my contact.php

<?php 

    if(isset($_POST['submit'])) {
    $to = "ekalaivan@gmail.com";
    $subject = $_POST['posRegard'];
    $name = $_POST['posName'];
    $email = $_POST['posEmail'];

    if ( preg_match( "/[\r\n]/", $posName ) || preg_match( "/[\r\n]/", $posEmail ) ) {
    header( 'Location: http://swedsb.com/' );
    }

    $message = $_POST['posText'];
    $body = "$name has sent you a greeting. \n E-Mail: $email\nMessage:\n $message";

    mail($to, $subject, $body);
    header( 'Location: http://swedsb.com/' );
 } 
 else {echo "blarg!";}?>


PHP will always say the mail was send... Checks the path of sendmail in your php.ini file...


There is no space between

<?phpif

the script looks good you can check the ini file, or contact to ur server admin if the mail settings are on.


I recommend checking the mail server logs. Generally speaking you'll find them somewhere like: /var/log/mail.log.

After locating the log file, run the script and then immediately review the log file and see what happens. Search for the recipient (to address) e-mail to find entry in the log.

Best of luck!

p.s. This script has some serious security problems as-is. Expect spammers will try and trick your code into sending e-mails on their behalf. In particular is important to check any variables which will be used as part of the e-mail headers or content. These values should be sanitized. Look for line feeds, multipart/mixed MIME content boundary markers, and BCC or other headers, and anything else which looks funny. Always send from an explicit e-mail address you provide, do not use the from address the user enters in web form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜