Jump to content

Php mailing


Hellusius

Recommended Posts

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
[code]<?
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>
<? }; ?>[/code]

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

thanks for your time
Link to comment
Share on other sites

The reason may be this portion of the code.

[code=php:0]
$mailheader = "From: ".$_POST["email"]."\r\n";
[/code]

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

I would place the [code=php:0]$_POST['email'][/code] in the message body. Like this.

[code=php:0]
$MESSAGE_BODY .= $_POST['email'] . "<br />";
[/code]

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

Hope this helps,
Tom
Link to comment
Share on other sites

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 [code=php:0]$mailheader = "From: noreply@yourdomain.com\r\n";[/code]

Give that a shot.

Good luck,
Tom
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.