zero-perfoliate
zero-perfoliate

Author Topic: help requested with a formmail.php  (Read 301 times)

Offline GeekyWriter

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
help requested with a formmail.php
« on: April 19, 2010, 08:17:26 AM »
Hello,

I am very new and inexperienced at php.  I hope I can find help here.  I am trying to make a formmail.php email send work.  There is something in the code that does not make sense to me at all.  I took over the hosting of this site from someone else and need to make the form work.  Here is the code that I do not understand:

$TARGET_EMAIL = array(EMAIL_NAME."@domain-name\.com$",

                "^email-1@domain-name\.com$",

                "^email-2@domain-name\.com$");

I need to insert my own values for the above addresses.  Why is the domain name and extension separated like this: domain-name\.com?

Thank you

Offline drexl

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
Re: help requested with a formmail.php
« Reply #1 on: May 09, 2010, 04:03:45 PM »
 I think the slash is an escape character.

Offline drexl

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
Re: help requested with a formmail.php
« Reply #2 on: May 09, 2010, 08:15:04 PM »
Download        http://swiftmailer.org/downloads/get/Swift-4.0.6.tar.gz

and then upload it to your server. copy the code below into two files
one named form.html (arbitrary) and the php is named contact.php after filling in your mailserver address and your email and your name in the php script, put them in the Swift-4.0.6 folder on your server. then point your browser to the form.html file.




######### start html form ######################

<form action="http://yoursite/Swift-4.0.6/contact.php" method="post">

<font color="#000000">Your name</font><input name="name" size="40" type="text" />


<font color="#000000">Your email address</font>
<input name="email" size="40" type="text" />


<font color="#000000">Questions or comments:</font>


<textarea cols="40" rows="4" name="description"></textarea>
<span style="color: #000000;"><input type="reset" value="Clear" /><input type="submit" value="Send" /></span>
</form>
############### end of html doc ###################

############# start contact.php ####################

<?php

require_once 'lib/swift_required.php';


$email=$_POST['email'];
$description=$_POST['description'];
$name=$_POST['name'];

function doFormError($errString)

{
echo "$errString";
exit;}

if( !(ereg("^(.+)@(.+)\\.(.+)$",$email)) ) {
    doFormError("
<font size=5 color=#000000>You submitted an invalid email address.  Please go <a href='Javascript:history.go(-1);'>back[/url]&nbsp;and correct the error.</font>
");
exit;}

$transport = Swift_SmtpTransport::newInstance('your_mailserver', 25);
$mailer = Swift_Mailer::newInstance($transport);
$message=Swift_Message::newInstance();
$message->setSubject('Site Comments');
$message->setFrom(array("$email"=>"$name"));
$headers = $message->getHeaders();
$message->setTo(array('yourmail@hotmail.com'=> 'you'));
$message->setBody("$description");
$result=$mailer->send($message, $failures);

echo "Thank you for your comments. go <a href='Javascript:history.go(-1);'>back[/url]";

  ?>


to obtain your_mailserver info you must save the following code to a file and name it test.php (arbitrary).
############################

<?php

 # initialize sessions

 session_start();

 

 # set session variable to auto-increment

 $_SESSION['VAR'] += 1;

 echo "<p>If the following number increases everytime you hit the Refresh button, session

 variables are working:",$_SESSION['VAR'],"</p>";

 

 if (isset($_ENV["_FCGI_MUTEX_"])) echo "<p>FastCGI Enabled</p>";

 phpinfo();

 

?>

####################################
upload it, then point your browser to it, at the very top of the output it will show your mailservers address   it looks something like this:

Linux gator667.hostgator.com 2.6.33.1 #6 SMP PREEMPT Tue Mar 23 23:09:34 CDT 2010 i686

gator667.hostgator.com   is my mailserver, yours will be different.  :)









 

zero-perfoliate