Jump to content

stuck in email (minor problem)


Jaswinder

Recommended Posts

hey friends.. the script is sending email .. but the problem is email is not showing the name and the email id of the sender,, rather it showing the hosting provider name.. as it was sending email to not the sender.. hope i can clear my problem ..here is the code.

 

 <form action="feed1.php" method="post">
 <table width="100%">
<tr><td>Name</td><td><input type="text" name="name" /></td></tr>
<tr><td>E-mail Id</td> <td><input type="text" name="email" /></td></tr>
<tr><td>Subject</td><td><input type="text" name="subject"/></td></tr>
<tr><td>Message</td><td><textarea rows="10" cols="20" name="message"></textarea></td></tr>
<tr><td colspan="2"><input type="submit" value="Send mail" name="sub" /></td></tr>
</table>
</form>

 

feed1.php

<?php     
error_reporting(-1);
if (function_exists('mail'))
 {
extract($_POST);
if(!empty($name) && !empty($email) && !empty($subject) && !empty($message))
{
    if(filter_var($email, FILTER_VALIDATE_EMAIL))
    {
$to = "sehgal_jas@yahoo.com";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers.= "From: ".$name."<".$email.">";
// send message
if (mail($to, $subject, $message, $headers))
{
?>
<script type="text/javascript"> alert('Email Send')
     window.location='about.php'; </script>
<?php
}
else
{
?>
<script type="text/javascript"> alert('Sending Failed')
     window.location='about.php'; </script>
<?php
}
    }
else
{
?>
<script type="text/javascript"> alert('Enter valid Email id')
     window.location='about.php'; </script>
<?php
 }}
 else
 ?>
<script type="text/javascript"> alert('Enter all the fields')
     window.location='about.php'; </script>
<?php
 }
 else
{
?>
<script type="text/javascript"> alert('Mail function disabled.. Try again after sometime')
     window.location='about.php'; </script>
<?php

}
?>

 

Problem

The email is showing

 

From: xyz@host261.hostmonster.com (not the email id of the sender and not its name)..

 

any suggestions? you can check this form at http://www.poemquotejoke.com/about.php

Link to comment
Share on other sites

the person filling out the form may be who is providing his email address in one of your form fields, but the email is NOT being sent from that email address. it is being sent from the mail server at your web hosting.

 

you need to put the person's name/email into a Reply-to: header, not the From: header. the From: header should be an email address at your sending mail server, so that the receiving mail server will be less likely to mark the email as junk/spam.

Link to comment
Share on other sites

The proper formats are:

From: user@domain.com

OR

From: "user" <user@domain.com>

User should be quoted, also there needs to be an empty space between "user" and <user@domain.com>

 

 

check your headers next time.

 

$headers .= "From:".$name."<".$email.">\r\n";

 

There is no problem to use html entities.


$headers.= <<<EOD
From: "$name" <$email>
EOD;

OR

$headers.= <<<EOD
From: "$name" <$email>
EOD;

 

fixed it by removing the 'greater than' and 'less than' characters around the email address

No, it's not really necessary!

 

 

you need to put the person's name/email into a Reply-to: header, not the From: header. the From: header should be an email address at your sending mail server, so that the receiving mail server will be less likely to mark the email as junk/spam

Reply-to has nothing to do with the spam filter. In my opinion, the best way to verify that the email being delivered is to set a "FROM" addresses in the $header variable so that their system or the remote system knows whom to notify if delivery fails. There are lots of things that should be done to prevent emails going to a junk folder.

 

@Jaswinder, why don't you consider using some php mail library.

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.