Solved

Parts of Email not sending

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to count occurrences of each item in an array.

738 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