email form "help me"

Discussion in 'PHP' started by mirosoft1, Jan 16, 2008.

  1. #1
    i have an email form sending mail on junk and bulk i want to send to inbox what i can do????
     
    mirosoft1, Jan 16, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Post your code.
     
    nico_swd, Jan 16, 2008 IP
  3. mirosoft1

    mirosoft1 Well-Known Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    it is the code
    <?php
    $to = "you@yoursite.com";
    $subject = "Contact Us";
    $email = $_REQUEST['email'] ;
    $message = $_REQUEST['message'] ;
    $headers = "From: $email";
    $sent = mail($to, $subject, $message, $headers) ;
    if($sent)
    {print "Your mail was sent successfully"; }
    else
    {print "We encountered an error sending your mail"; }
    ?>
     
    mirosoft1, Jan 16, 2008 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Hotmail requires the email to have some specific headers. I don't know which ones by memory though. I'd suggest you have a look at phpmailer. http://phpmailer.sourceforge.net

    Take a look at the examples. Also set it up to use SMTP to send your mails.
     
    nico_swd, Jan 16, 2008 IP
  5. mirosoft1

    mirosoft1 Well-Known Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #5
    i test the code on this site but it send on the hotmail on inbox but on yahoo send to bulk
     
    mirosoft1, Jan 16, 2008 IP
  6. shyju

    shyju Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    try with this sample code

    <?php
    require("class.phpmailer.php");
    $mail = new PHPMailer();
    $subject = 'Test Mail';
    $content = 'Test Mail';
    $to = 'to@domain.com';
    $mail->From = "u@domain.org";
    $mail->FromName = "u";
    $mail->AddReplyTo("u@domain.org","u");
    $mail->Username = $smtp_username;
    $mail->Password = $smtp_password;
    $mail->Host = $smtp_server;
    $mail->IsHTML(true);
    $mail->Mailer = "mail";
    $mail->CharSet = "utf-8";
    $mail->Subject = stripcslashes($subject);
    $mail->AltBody = " ";
    $mail->AddAddress($to,'toName');
    $mail->Body = $content;
    $mail->AltBody = "";
    if(!$mail->Send()) {
    echo "Message was not sent <p>";
    echo "Mailer Error: " . $mail->ErrorInfo;
    }else{
    echo "ok ";
    }
    ?>
     
    shyju, Jan 16, 2008 IP
  7. mirosoft1

    mirosoft1 Well-Known Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #7
    not working with me
     
    mirosoft1, Jan 16, 2008 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    Can you specify "not working"? Doesn't it send the mail at all or does it go to the junk folder again? Did you configure the code above correctly?
     
    nico_swd, Jan 16, 2008 IP
  9. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #9
    This construction is very dangerous.

    Someone can pass a value for "email" which looks like this:

    \nCc: spamvictim1, spamvictim2, spamvictim3, etc.\n\nBuy Viagra now!

    and spam the whole universe. They can even use it to send viruses and other malicious attachments. And it will be traced back to your server.

    Anything that goes into an email header must be meticulously sanitised.
     
    SmallPotatoes, Jan 16, 2008 IP
  10. mirosoft1

    mirosoft1 Well-Known Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #10
    not sending the mail not on inbox and not on bulk
    but the page give me ok
     
    mirosoft1, Jan 16, 2008 IP
  11. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #11
    Is the code you posted above exactly the code you used? Or did you modify it for your needs?

    Can you post the exact code you used, including the HTML form?
     
    nico_swd, Jan 16, 2008 IP