Jump to content

Send Mail to my self and a User * NEW TO PHP


jamesclues

Recommended Posts

Hi I am very new to PHP i used to use asp but I thought I would try PHP

 

My Problem is changing a send mail script

 

 

FIELD NAMES BELOW.

 

firstname

surname

address

town

postocde

telephone

emailaddress

enquiry

 

------------------------------------

 

Email Example Sent to My Self  me@domain.com

 

Subject New Enquiry from Web Site.

 

firstname

surname

address

town

postocde

telephone

emailaddress

enquiry

 

-------------------------------------

 

Email Example Sent to User to Confirm

 

Dear firstname

 

Subject New Enqury from domain.com

 

Thank you for you email we will be in touch soon.

 

 

after send redirected to a THANKS.PHP

 

I dunno how to do this

Link to comment
Share on other sites

 

Well the only code I have is in ASP.  So I need to convert this into PHP I have never used PHP in my life till today and have no idea where to start I have search forums and web sites but nothing what i need :(

 

<%

dim firstname
dim surname
dim address
dim town
dim postocde
dim telephone
dim emailaddress
dim enquiry


firstname=request.form("firstname")
surname=request.form("surname")
address=request.form("address")
town=request.form("town")
postocde=request.form("postocde")
telephone=request.form("telephone")
emailaddress=request.form("emailaddress")
enquiry=request.form("enquiry")


dim msg1
msg1="<p>Contact Request from Web Site</p>"
msg1=msg1 & "<b>First Name:</b> " & firstname & "<br>"
msg1=msg1 & "<b>Last Name:</b> " & surname & "<br>"
msg1=msg1 & "<b>Last Name:</b> " & address & "<br>"
msg1=msg1 & "<b>Last Name:</b> " & town & "<br>"
msg1=msg1 & "<b>Last Name:</b> " & postocde & "<br>"
msg1=msg1 & "<b>Last Name:</b> " & telephone & "<br>"
msg1=msg1 & "<b>Last Name:</b> " & emailaddress & "<br>"
msg1=msg1 & "<b>Last Name:</b> " & enquiry & "<br>"




Set JMail = Server.CreateObject("JMail.SMTPMail")
  JMail.ServerAddress = "smtp.domain.co.uk:25" 
  JMail.Sender = emailaddress
     JMail.Subject = "Subject Enquiry"
     JMail.AddRecipient "info@domain.com"
  JMail.ContentType = "text/html"
  JMail.Body = msg1
     
  JMail.Priority = 0
   JMail.Execute 
%>


<%
dim msg2
msg2="<b>Dear " & firstname & "</b>"
msg2=msg2 & "<p>Thank you for contacting us.</p>"
msg2=msg2 & "<p>We will contact you in the next 24 hours</p>"


Set JMail = Server.CreateObject("JMail.SMTPMail")
  JMail.ServerAddress = "smtp.Domain.co.uk:25" 
  JMail.Sender = "info@Domain.com"
     JMail.Subject = "Doman Enquiry"
     JMail.AddRecipient emailaddress
  JMail.ContentType = "text/html"
  JMail.Body = msg2
   
  JMail.Priority = 0
   JMail.Execute 
%>

<html><head><meta http-equiv="refresh" 

content="1;url=http://www.domain.com/thankyou.asp"><title>Domain</title>
</head><br><br><br>
<br><center><font color=#000000 face=arial size=3>
<b>SENDING EMAIL TO DOMAIN.COM</font><br><br>
<font color=#000000 face=arial size=4>
<br>http://www.Domains.com</b></font></center>
</body></html>

Link to comment
Share on other sites

Well if you're familiar with asp you should be pretty adaptable. CLICKY That's the page of the manual you need; have a read through that and it will explain everything you need to send the mail.

 

If you're getting details from a web form that require assigning to a var I'd recommend looking at some basic tutorials so you get the jist of variables and superglobals (the basics) of php.

Link to comment
Share on other sites

I have a Form which is on contact.html and posts the data to send.php

 

Contact Form Fields

 

FIELD NAMES BELOW.

 

name

address

town

postocde

telephone

email

enquiry

 

 

 

<?

if($_POST["send"]) {

 

//collect post variables

$name = $_POST["name"];

$address = $_POST["address"];

$town = $_POST["town"];

$postocde = $_POST["postocde"];

$telephone = $_POST["telephone"];

$email = $_POST["email"];

$enquiry = $_POST["enquiry"];

 

 

//build email body

$body .= "Name: $name \n";

$body .= "Address: $address \n";

$body .= "Town: $town \n";

$body .= "Postcode: $postcode \n";

$body .= "Telephone: $telephone \n";

$body .= "Email: $email \n";

$body .= "Enquiry: $enquiry \n";

 

//create email headers

$headers = 'From: '.$email. "\r\n" .

  'Reply-To: ' . "\r\n" .

  'X-Mailer: PHP/' . phpversion();

 

//send

$send = mail("info@domain.co.uk","Online Enquiry");

 

?>

 

<?

if($_POST["send"]) {

 

//collect post variables

$name = $_POST["name"];

$email = $_POST["email"];

 

 

//build email body

$body .= "Name: $name \n";

$body .= "Thank you for your Enquiry \n";

 

 

//create email headers

$headers = 'From: 'info@domain.co.uk "\r\n" .

  'Reply-To: ' . "\r\n" .

  'X-Mailer: PHP/' . phpversion();

 

//send

$send = mail("$email","Online Enquiry");

 

?>

 

Still having issue got some code off a web site but still does not work :(

Link to comment
Share on other sites

Parse error: syntax error, unexpected T_STRING in send.php on line 47

 

Line 47 = $headers = 'From: 'test@domain.com' "\r\n" .

 

 

Full Code of Area where problem Happening.

 

//create email headers

$headers = 'From: 'test@domain.com' "\r\n" .

'Reply-To: ' . "\r\n" .

'X-Mailer: PHP/' . phpversion();

Link to comment
Share on other sites

$headers = 'From: 'test@domain.com' "\r\n". //rest of headers code continues...thats why theres dot..

 

should probably read

$headers = "From: 'test@domain.com' \r\n". //rest of headers code continues...thats why theres dot..

of possibly

$headers = 'From: 'test@domain.com'."\r\n". //rest of headers code continues...thats why theres dot..

 

The apostrophe, and/or quotation marks are were not matching up...

 

Link to comment
Share on other sites

Still not working now i get  Parse error: syntax error, unexpected $end in send.php on line 54

 

Line 54 is ?>

 

<?
if($_POST["send"]) { 

//collect post variables
$name = $_POST["name"];
$address = $_POST["address"];
$town = $_POST["town"];
$postocde = $_POST["postocde"];
$telephone = $_POST["telephone"];
$email = $_POST["email"];
$enquiry = $_POST["enquiry"];


//build email body
$body .= "Name: $name \n";
$body .= "Address: $address \n";
$body .= "Town: $town \n";
$body .= "Postcode: $postcode \n";
$body .= "Telephone: $telephone \n";
$body .= "Email: $email \n";
$body .= "Enquiry: $enquiry \n";

//create email headers
$headers = 'From: '.$email. "\r\n" .
   'Reply-To: ' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

//send
$send = mail("test@domain.com","Online Enquiry",$body,$headers);

?>

<?
if($_POST["send"]) { 

//collect post variables
$name = $_POST["name"];
$email = $_POST["email"];


//build email body
$body .= "Name: $name \n";
$body .= "Thank you for your Enquiry \n";


//create email headers
$headers = "From: 'test@domain.com' \r\n". 
   'Reply-To: ' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

//send
$send = mail("$email","Online Enquiry",$body,$headers);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.