Solved

Parts of Email not sending

Posted on 2014-02-28
2
341 Views
Last Modified: 2014-03-01
I have a page that sends an email to a friend of choice.  It's working except for a few lines.

Subject, Message, I think thats it.  The code.

<?php
		$error		= '';
		$subject	= '';
		$friendname	= '';
		$friendemail= '';
		$yourname	= '';
		$youremail	= '';
		$message	= '';
		$verify		= '';

		if(isset($_POST['contactus'])) {

		$subject	= $_POST['Bri Cooper - Mezzo Soprano'];
		$friendname	= $_POST['friendname'];
		$friendemail= $_POST['friendemail'];
		$yourname	= $_POST['yourname'];
		$youremail	= $_POST['youremail'];
		$message	= $_POST['message'];
		$verify		= $_POST['verify'];

		if(trim($friendname) == '') {
			$error = '<div class="error_message">Attention! You must enter your friends name.</div>';
		} else if(trim($friendemail) == '') {
			$error = '<div class="error_message">Attention! Please enter your friends email address.</div>';
		} else if(!isEmail($friendemail)) {
			$error = '<div class="error_message">Attention! Invalid e-mail address, try again.</div>';
		} else if(trim($yourname) == '') {
			$error = '<div class="error_message">Attention! You must enter your name.</div>';
		} else if(trim($youremail) == '') {
			$error = '<div class="error_message">Attention! Please enter your email address.</div>';
		} else if(!isEmail($youremail)) {
			$error = '<div class="error_message">Attention! Invalid e-mail address, try again.</div>';
		} else if(trim($message) == '') {
			$error = '<div class="error_message">Attention! Please enter a message.</div>';
		} else if(trim($verify) == '') {
			$error = '<div class="error_message">Attention! Please enter the verification number.</div>';
		} else if(trim($verify) != '4') {
			$error = '<div class="error_message">Attention! The verification number is incorrect.</div>';
		}

		if($error == '') {

			if(get_magic_quotes_gpc()) {
				$comments = stripslashes($comments);
			}

		$address = $friendemail;


		$e_subject = 'You\'ve been contacted by ' . $yourname . '.';


		$e_body = "You have been contacted by ' . $yourname . ' with regards to ' . $subject . ', their additional message is as follows.\r\n\n";
		$e_content = "\"$message\"\r\n\n";

		$e_reply = "You can contact ' . $yourname . ' via email, ' . $youremail . '";

		$message = $e_body . $e_content . $e_reply;

		if(mail($address, $e_subject, $message, "From: $youremail\r\nReply-To: $friendemail\r\nReturn-Path: $youremail\r\n"))
		{
			 echo "<div id='success_page'>";
			 echo "<h1>Email Sent Successfully.</h1>";
			 echo "<p>Thank you <strong>$yourname</strong>, your message has been sent.</p>";
			 echo "</div>";
		 } else echo "Error. Mail not sent";

		}
	}

		if(!isset($_POST['contactus']) || $error != '') // Do not edit.
		{
?>

Open in new window


The site page...

http://www.bricooper.net/popup.php

This is what is being sent.


You have been contacted by ' . Sid . ' with regards to ' . . ', their additional message is as follows.

"Sid Vicious"

You can contact ' . Sid . ' via email, ' . sid@gfhf.com . '

It should be....
You have been contacted by Sid Vicious with regards to Bri Cooper - Mezzo Soprano.  Their additional message is as follows:  Check her out.

Sid Vicious is $yourname
popup.php
0
Comment
Question by:DS928
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 39896810
First of all, tis doesn't make sense:

$subject	= $_POST['Bri Cooper - Mezzo Soprano'];

Open in new window


if youwant set $subjet to 'Bri Cooper - Mezzo Soprano' you ust write

$subject	= 'Bri Cooper - Mezzo Soprano';

Open in new window


About the rest ('Check herout' and Sid Vicious) try to var_dump the $_POST array this way:

		if(isset($_POST['contactus'])) {
                    echo "<pre>";
                    var_dump($_POST);
                    echo "</pre>";

Open in new window


Aside note: y can siply write:

$e_content = "$message\r\n\r\n";
0
 

Author Closing Comment

by:DS928
ID: 39896850
Works now. Thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question