dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Email code is not working

  1. #1
    Join Date
    Jun 2008
    Posts
    106

    Email code is not working

    Hi friends,

    I have developed page with mail() function.Page worked fine 1 week back but now that code is not working fine.

    Please help me to resolve this issue.

    The below is the code,


    <?PHP

    ini_set('SMTP', 'loclhost'); //Suggested by "Some Guy"
    ini_set('SMTP_port', 25); //Suggested by "Some Guy"

    $name = $_REQUEST['name']; //senders name
    $email = $_REQUEST['email'];; //senders e-mail adress
    $message = $_REQUEST['message'];; //senders e-mail adress
    $contact = $_REQUEST['contact'];; //senders e-mail adress

    $recipient = "admin1@xxx.com"; //recipient
    $mail_body .= "Name :".$name."\n"; //mail body
    $mail_body .= "Email-Id :".$email."\n"; //mail body
    $mail_body .= "Contact No :".$contact."\n"; //mail body
    $mail_body .= "Address :".$address."\n"; //mail body
    $mail_body .= "Message :".$message."\n"; //mail body

    $subject = "Enquiry Form"; //subject
    $header = "From: ". $name . " <" . $email . ">\r\n"; //optional headerfields

    //ini_set('sendmail_from', 'admin@xxx.com'); //Suggested by "Some Guy"
    if(!($name)=="")
    {
    mail($recipient, $subject, $mail_body, $header); //mail command
    }
    ?>

    Regards,
    Punitha Pary

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,802
    whats if(!($name)=="") all about?

    If you are wanting to test for empty fields, you do it long before you want to send an email, also, its likely that you are wanting to if(!empty($name)) check the value for $name
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  3. #3
    Join Date
    Jun 2008
    Posts
    106
    Quote Originally Posted by \\.\ View Post
    whats if(!($name)=="") all about?

    If you are wanting to test for empty fields, you do it long before you want to send an email, also, its likely that you are wanting to if(!empty($name)) check the value for $name
    After removing this code if(!($name)=="") also my email is not working
    The below is the code,


    <?PHP

    ini_set('SMTP', 'loclhost'); //Suggested by "Some Guy"
    ini_set('SMTP_port', 25); //Suggested by "Some Guy"

    $name = $_REQUEST['name']; //senders name
    $email = $_REQUEST['email'];; //senders e-mail adress
    $message = $_REQUEST['message'];; //senders e-mail adress
    $contact = $_REQUEST['contact'];; //senders e-mail adress

    $recipient = "admin1@xxx.com"; //recipient
    $mail_body .= "Name :".$name."\n"; //mail body
    $mail_body .= "Email-Id :".$email."\n"; //mail body
    $mail_body .= "Contact No :".$contact."\n"; //mail body
    $mail_body .= "Address :".$address."\n"; //mail body
    $mail_body .= "Message :".$message."\n"; //mail body

    $subject = "Enquiry Form"; //subject
    $header = "From: ". $name . " <" . $email . ">\r\n"; //optional headerfields

    mail($recipient, $subject, $mail_body, $header); //mail command

    ?>

    Regards,
    Punitha Pary

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,802
    You should be consulting your web host on what they require in your code to enable you to send emails.

    Working on suggestions by someguy isn't going to help you and please, wrap your code in forum tags, it makes it easier to read.
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles