herghost Posted November 4, 2009 Share Posted November 4, 2009 Hi all, I have the below: <?php require_once "Mail.php"; $from = $_GET['email']; $to = "Contact <[email protected]>"; $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 https://forums.phpfreaks.com/topic/180256-solved-combine-variables-to-email/ Share on other sites More sharing options...
Bricktop Posted November 4, 2009 Share Posted November 4, 2009 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 <[email protected]>"; $subject = $_GET['subject']; $message = $_GET['message']; $name = $_GET['name']; $body = "$name\n\n$message\n\n"; Hope this helps. Link to comment https://forums.phpfreaks.com/topic/180256-solved-combine-variables-to-email/#findComment-950873 Share on other sites More sharing options...
herghost Posted November 4, 2009 Author Share Posted November 4, 2009 Thanks, that works great Link to comment https://forums.phpfreaks.com/topic/180256-solved-combine-variables-to-email/#findComment-950903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.