Problem in Sending mail and a responce mail.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vivekgs2007
    New Member
    • Mar 2010
    • 62

    Problem in Sending mail and a responce mail.

    Hi sir,
    I Have created a feedback page in php.Its all working properly.but the problem is that, when any one give the feedback it stores in database, but a mail is not sent to owner...is that i have to configure in phpmailer function in server.. the code is
    Code:
    		$mail_date = date("d-m-Y");
    		//$to = "info@eitech.in";
    		$to = "user@example.com";
    		$subject = "Feedback posted in www.eitech.in dated".$mail_date;
    		$message = "Name : ".$Name."<br/>"."Address: ".$Address."<br/>"."Email : ".$Email."<br/>"."Fax: ".$Fax."<br/>"."Message :".$Message."<br/>";
    		$from = $Email;
    		$headers = "From: .$from";
    		mail($to,$subject,$message,$headers);
    		echo "<br/><center><style='font-size:1.2em;color:#0557A9;'>Thank You For Sending The Feedback To Us,<br/>We Will Get Back To You With A solution To Your Query.</center><br/>";
    The link of the site page is http://www.eitech.in/prj_feedback.php
    Last edited by Atli; Mar 29 '10, 05:13 AM. Reason: Removed real email address. Use example values for email addresses please!
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    Do you have the error messages turned on?

    To use the mail function, you need to have a SMTP server set up. On Linux, there would need to be a sendmail server set up. On Windows, a SMTP server. Also, on Windows you may need to alter the "SMTP" and "smtp_port" directives in the "php.ini" file to match the values for your STMP server.

    If using a local server is not an option, you may want to consider upgrading to one of the mailer classes, such as PHPMailer or Swift Mailer. They are generally easier to work with.

    Comment

    • vivekgs2007
      New Member
      • Mar 2010
      • 62

      #3
      Originally posted by Atli
      Hey.

      Do you have the error messages turned on?

      To use the mail function, you need to have a SMTP server set up. On Linux, there would need to be a sendmail server set up. On Windows, a SMTP server. Also, on Windows you may need to alter the "SMTP" and "smtp_port" directives in the "php.ini" file to match the values for your STMP server.

      If using a local server is not an option, you may want to consider upgrading to one of the mailer classes, such as PHPMailer or Swift Mailer. They are generally easier to work with.
      Sir if i used in localhost..i need to configure smtp mailer...i used directly in the server by uploading..then how to configure the phpmailer function in my server...
      sir the code is correct na sir...

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        The code you are using should work fine. If it isn't working, the server you are using must not be set up to send emails.

        then how to configure the phpmailer function in my server
        You must not confuse the mail() function and PHPMailer. They are two completely different things. - The mail() function is just meant to be used to send simple emails on servers with a very simple, standard mail server setup. - The PHPMailer or Swift Mailer classes are much more advanced. They can handle all sorts of server setups and are much more easily configurable and offer much more detailed debugging.

        Whatever you do, you need to figure out how your mail server is set up. If it is a basic sendmail or local SMTP server, you may well be able to use the mail() function. - If it is anything more complex, you may want to use PHPMailer (or Swift Mailer) instead.

        Comment

        • vivekgs2007
          New Member
          • Mar 2010
          • 62

          #5
          ok Thank you sir, I Will work on it and if any error comes, I will get back to u,Thank you for giving me a suggestion to me...

          Comment

          • vivekgs2007
            New Member
            • Mar 2010
            • 62

            #6
            Hello sir,
            As u told me about the phpmailer, i downloaded and work in that but i am not getting any error in that code, the mail is not sending, please help me in that...here is the code
            Code:
            require_once('class.phpmailer.php');
            //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
            $mail_date = date("d-m-Y");
            $body             = file_get_contents('contents.html');
            $body             = eregi_replace("[\]",'',$body);
            $mail             = new PHPMailer(); // defaults to using php "mail()"
            
            
            
            
            
            $mail->SMTPAuth   = true;                  // enable SMTP authentication
            //$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
            $mail->Host       = "smtp.eitech.in";      // sets GMAIL as the SMTP server
            $mail->Port       = 25;  
            $mail->Username = "username"; 
            $mail->Password = "password"; 
            
            
            $mail->IsHTML(true);	
            
            $mail->SetFrom($Email, 'First Last');
            
            
            
            $address = "swd@eitech.in";
            $mail->AddAddress($address, "vivek");
            
            $mail->Subject    = "PHPMailer Test Subject via mail(), basic";
            
            //$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
            
            $mail->MsgHTML($body);
            
            
            echo "<br/><center><style='font-size:1.2em;color:#0557A9;'>Thank You For Sending The Feedback To Us,<br/>We Will Get Back To You With A solution To Your Query.</center><br/>";
            check it here...

            Comment

            Working...