Jump to content


Photo

Php mailing


  • Please log in to reply
5 replies to this topic

#1 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 01 September 2006 - 09:57 AM

I looked up some code for a mailing page, so people can instant mail to the contact mail of the website, but it does not really work.

so far I got
<?
if ($_POST["email"]<>'') {
$ToEmail = 'harold_break@hotmail.com';
$EmailSubject = 'Contact us';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
Your message was sent
<? } else { ?>
<form action="contactus.php" method="post">
<table width="400" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="29%" class="bodytext">Your name:</td>
<td width="71%"><input name="name" type="text" id="name" size="32"></td>
</tr>
<tr>
<td class="bodytext">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr>
<tr>
<td class="bodytext">Comment:</td>
<td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td>
</tr>
<tr>
<td class="bodytext">&nbsp;</td>
<td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form>
<? }; ?>

I can send the mails, but they do not arrive into the mail, is there something I am doing wrong?

thanks for your time

#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 01 September 2006 - 10:10 AM

The reason may be this portion of the code.

$mailheader = "From: ".$_POST["email"]."\r\n";

Change this to an email address that is known to the server ..i.e. you @yourdomain.com

I would place the
$_POST['email']
in the message body. Like this.

$MESSAGE_BODY .= $_POST['email'] . "<br />";

Give it a try. I would be willing to bet that this will fix your problem.

Hope this helps,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#3 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 01 September 2006 - 10:22 AM

well I don't have an email on my server

and I don't get the second things, which line do I exactly need to change?

#4 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 01 September 2006 - 10:39 AM

Ok I just looked at the script you already have the users email in the message body. So disregard that. Now if you do not have an email address with the mail server..? Maybe your host has the fake mail enabled. So try
$mailheader = "From: noreply@yourdomain.com\r\n";

Give that a shot.

Good luck,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#5 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 01 September 2006 - 10:44 AM

Doesn't change a thing, sadly :(

#6 Hellusius

Hellusius
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 01 September 2006 - 03:32 PM

I still have not figured it out, I asked a few other people I whom know a bit of PhP as well, but they didn't have a clue either, anymore suggestions are welcome =).




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users