Jump to content

[SOLVED] combine variables to email


herghost

Recommended Posts

Hi all,

 

I have the below:

 

<?php
require_once "Mail.php";

$from = $_GET['email'];
$to = "Contact <contact@stockluck.com.au>";
$subject = $_GET['subject'];
$body = $_GET['message'];
$name = $_GET['name'];


$host = "ssl://mail.stockluck.com.au";
$port = "465";
$username = "mail+stockluck.com.au";
$password = "*******";


$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject,
'Name' => $name);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body, $name);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {

  echo("<br><br><p>Message successfully sent!<br>You will receive a reply within 24 hours, thank you for contacting Stockluck.com.au!</p>");
}
?><br>
<br>
<br>
<center>
<a href="../index.php" title="Cancel & close dialog" onclick="Modalbox.hide(); return false;">Close</a><br />

 

Which all works kinda!

 

Basically I want to attach the $name variable to the $body so I know the name of the person sending the message, at the moment it does not appear anywhere on the sent email.

 

Many Thanks

Link to comment
Share on other sites

Hi herghost,

 

Assign a $message variable and then create a new $body variable with the required variables combined.  For example:

 

$from = $_GET['email'];
$to = "Contact <contact@stockluck.com.au>";
$subject = $_GET['subject'];
$message = $_GET['message'];
$name = $_GET['name'];

$body = "$name\n\n$message\n\n";

 

Hope this helps.

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.