Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Parts of Email not sending

Posted on 2014-02-28
2
Medium Priority
?
350 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
2 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

886 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