Solved

Parts of Email not sending

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

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now