Auto Respond Message By Using Gmail Smtp For Form Submit

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 23, 2009, 06:47 PM
431449 members and 298469 Topics
Latest Member: afam.ozo
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Auto Respond Message By Using Gmail Smtp For Form Submit
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Auto Respond Message By Using Gmail Smtp For Form Submit  (Read 467 views)
nigil
Auto Respond Message By Using Gmail Smtp For Form Submit
« on: March 09, 2009, 12:41 PM »

Hi i am  a newbie here,

I own a website, In my contact page ( http://www.nigil.uuuq.com/Contact Me/ )there is fileds for submitting name, email, and comments from users. By using a php file i am storing these data in to a txt file in the server. what i want to do is to sent an auto respond message to these email id's when they gets submitted using my gmail smtp mail account. i am using a free host so i dont have any mailserver. Is it possible. if possilble please help me to do it. any help would be well appreciated.

given below the code for the html page for submiting data.

<form action="http://www.mysite.com/mailer.php?savedata=1" method="post">
Your Name: <input type="text" name="name"><br>
Your Email : <input type="text" name="email"><br><br>
Your Message:<br> <textarea name="message" rows="1" cols="1"></textarea><br>
<input type="submit" name="submit" value="Submit">
</form>

given below the code for the php page for storing data.

<?php
$savedata = $_REQUEST['savedata'];
if ($savedata == 1){
$data = $_POST['name'];
$data1 .= $_POST['email'];
$data2 .= $_POST['message'];
$file = "YOURDATAFILE.txt";
$fp = fopen($file, "a") or die("Couldn't open $file for writing!");
fwrite($fp, "*************** \n" );
fwrite($fp," Name: $data \n");
fwrite($fp," Email: $data1 \n");
fwrite($fp," Message: $data2 \n");
fwrite($fp, "*************** \n" );
fclose($fp);
}
header('Location: http://www.mysite.com/Thank You');
?>

Thanks in Advance,

Nigil.
http://www.nigil.uuuq.com
javarules (m)
Re: Auto Respond Message By Using Gmail Smtp For Form Submit
« #1 on: March 16, 2009, 12:09 AM »

Traditionally if you host have a server configured, i mean a mail server

Code:
<?
$to = "webmaster@php-scripts.com";
$from_header = "From: $from";
if($contents != "")
{
   //send mail - $subject & $contents come from surfer input
   mail($to, $subject, $contents, $from_header);
   // redirect back to url visitor came from
   header("Location: $HTTP_REFERER");
}
  else
{
   print("<HTML><BODY>Error, no comments were submitted!");
   print("</BODY></HTML>");
}
?>

But if not, u will want to specify your own server connections to use right?

I use linux so the first solution I will profer is one that works on linux, there is a PEAR interface called Mail. I dont know if it is included on windows or not, but on linux, if u insatll PHP Pear, then this code will work

Code:
<?php
include("Mail.php");
/* mail setup recipients, subject etc */
$recipients "feedback@yourdot.com";
$headers["From"] = "user@somewhere.com";
$headers["To"] = "feedback@yourdot.com";
$headers["Subject"] = "User feedback";
$mailmsg "Hello, This is a test.";
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "smtp.mycorp.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "smtpusername";
$smtpinfo["password"] = "smtpPassword";
/* Create the mail object using the Mail::factory method */
$mail_object =& Mail::factory("smtp"$smtpinfo);
/* Ok send mail */
$mail_object->send($recipients$headers$mailmsg);
?>


I found this blog while googling, I never tried it I hope it works
http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html

last option, go inside the php.ini file and tinker with the configuration in [mail function] section.
 Pls Can Anyone Help Me Via "gotoassist"? I Am Going Nuts!  Where Can I Learn Programming  New To Programming  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.