Solved

Parts of Email not sending

Posted on 2014-02-28
2
335 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 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

763 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