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,220
    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
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  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,220
    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.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

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