/    Sign up×
Community /Pin to ProfileBookmark

php – send mail

hello, i use the code below to send e-mail from web form. everything is fine and works corretly.. only thing i worry about is that in gmail and some other … mail appears in spam folder instead of inbox. can i somehow correct this?

[code=php]if ($_POST[‘sendmail’])
{
$recipient = $_POST[‘to’];
$email = $_POST[’email’];
$name = $_POST[‘name’];
$feedback = $_POST[‘feedback’];

if(($recipient) == ”) { $toerr = 1; } else { $toerr = 0; }
if(($email) == ”) { $emailerr = 1; } else { $eamilerr = 0; }
if(($name) == ”) { $nameerr = 1; } else { $nameerr = 0; }
if(($feedback) == ”) { $feederr = 1; } else { $feederr = 0; }

$error = 0;

if(($toerr) == 1)
{
$toalert = “აირჩიეთ სად აგზავნით წერილს”;
$error = $error + 1;
}
if(($emailerr) == 1)
{
$emailalert = “მიუთითეთ ელექტრონული ფოსტა”;
$error = $error + 1;
}
if(($nameerr) == 1)
{
$namealert = “მიუთითეთ სახელი”;
$error = $error + 1;
}
if(($feederr) == 1)
{
$feedalert = “დაწერეთ თქვენი შენიშვნა/კომენტარი”;
$error = $error + 1;
}

if(($email) !== ”)
{
if(eregi(“^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$”, $email))
{
$emailalert = “”;

}
else
{
$emailalert = “მიუთითეთ სწორი ელ-ფოსტა. მაგ ([email protected])”;
$error = $error + 1;
}
}

if (($error) > 0)
{

$MailmeError .= “<table style=’padding-left:30px;’ cellpadding=’0′ cellspacing=’0′ border=’0′>
<tr><td style=’padding-top:40px; padding-bottom:20px;’ colspan=’3′><img src=’./global-images/send_comment.jpg’></td></tr>
<form action=’index.php?page=11&act=sendmsg’ method=’POST’ name=’sendmsg'”>
<TR><TD style=”width:100px;”><img src=’./global-images/towhom.jpg’></TD><TD>
<SELECT name=”to” style=’border:1px #979797 solid; padding-left:2px; font-size:11px; font-family:BPG Glaho Arial V5; color:#979797;’>
<option disabled=’disabled’ selected=’SELECTED’>———- &#4315;&#4312;&#4323;&#4311;&#4312;&#4311;&#4308;&#4311; &#4309;&#4312;&#4321; &#4323;&#4306;&#4310;&#4304;&#4309;&#4316;&#4312;&#4311; ———-</option>
<option style=”color:#444444;” value=’[email protected]’>&#4332;&#4308;&#4320;&#4312;&#4314;&#4312; &#4307;&#4312;&#4320;&#4308;&#4325;&#4330;&#4312;&#4304;&#4321;</option>
<option style=”color:#444444;” value=’[email protected]’>&#4312;&#4316;&#4324;&#4317;&#4320;&#4315;&#4304;&#4330;&#4312;&#4323;&#4314;&#4312; &#4322;&#4308;&#4325;&#4316;&#4317;&#4314;&#4317;&#4306;&#4312;&#4308;&#4305;&#4312;&#4321; &#4313;&#4304;&#4311;&#4308;&#4307;&#4320;&#4304;&#4321;</option>
</SELECT>
</TD><TD style=’padding-left:5px; font-size:10px; color:#b80000;’>”.$toalert.”</TD></TR>
<tr><td style=”width:100px;”><img src=’./global-images/your_name.jpg’><td><input style=’border:1px #979797 solid; width:236px; padding-left:2px; font-size:11px; font-family:BPG Glaho Arial V5;’ type=’text’ name=’name’></td><td style=’padding-left:5px; font-size:10px; color:#b80000;’>”.$namealert.”</td></tr>
<tr><td style=”width:100px;”><img src=’./global-images/email.jpg’></td><td><input style=’border:1px #979797 solid; width:236px; padding-left:2px; font-size:11px; font-family:BPG Glaho Arial V5;’ type=’text’ name=’email’></td><td style=’padding-left:5px; font-size:10px; color:#b80000;’>”.$emailalert.”</td></tr>
<tr><td style=”width:100px;”><img src=’./global-images/comment.jpg’></td><td colspan=’2′ style=’padding-left:5px; font-size:10px; color:#b80000;’>”.$feedalert.”</td></tr>
<tr><td colspan=’3′><textarea name=’feedback’ style=’border:1px #979797 solid; font-size:11px; font-family:BPG Glaho Arial V5;’ cols=’65’ rows=’10’></textarea></td></tr>
</table>
<div style=’padding-left:360px; padding-top:10px;’><input type=’submit’ name=’sendmail’ value=’&#4306;&#4304;&#4309;&#4306;&#4310;&#4304;&#4309;&#4316;&#4304;’></div>
</form>”;

print $MailmeError;
}
else
{
print ” <div style=”style=’font-size:14px; font-family:sylfaen; font-weight:bold; color:#b80000;’ “>”;

/* recipients */
$to1 = $recipient;

/* message */
$name1 = $name;
$email1 = $email;
$feedback1 = $feedback;

$message1 .= “<div style=”height:30px; padding-top:10px; font-family:BPG Glaho Arial V5; font-size:11px; color:#444444;”>&#4306;&#4304;&#4315;&#4317;&#4315;&#4306;&#4310;&#4304;&#4309;&#4316;&#4312;&#4321; &#4321;&#4304;&#4334;&#4308;&#4314;&#4312; :<B>”.$name1.”</B></div>rn”;

print “<br />”;

$message1 .= “<div style=”height:30px; font-family:font-family:BPG Glaho Arial V5; font-size:11px; color:#444444;”>&#4308;&#4314;-&#4324;&#4317;&#4321;&#4322;&#4304; :<B>”.$email1.”</B></div>rn”;
//print “<br />”;
$message1 .= “<div style=”height:30px; font-family:font-family:BPG Glaho Arial V5; font-size:11px; color:#444444;”>&#4332;&#4308;&#4320;&#4312;&#4314;&#4312;:</div>rn”;
$message1 .= “<div style=”font-size:11px; color:#444444;”>”.$feedback1.”</B></div>rn”;
//print “<br />”;
$subject1 = “&#4309;&#4308;&#4305; &#4324;&#4317;&#4320;&#4315;&#4312;&#4307;&#4304;&#4316; &#4315;&#4312;&#4326;&#4308;&#4305;&#4323;&#4314;&#4312;&#4304; &#4332;&#4308;&#4320;&#4312;&#4314;&#4312;. &#4304;&#4309;&#4322;&#4317;&#4320;&#4312;: $name1”;

/* To send HTML mail, you can set the Content-type header. */
$headers1 = “MIME-Version: 1.0rn”;
$headers1 .= “Content-type: text/html; charset=utf-8rn”;

/* additional headers */
$headers1 .= “To: “.$recipient.”rn”;
$headers1 .= “From: “.$email1.”rn”;
$headers1 .= “Reply-To: “.$email1.”rn”;
$headers1 .= “Cc: rn”;

/*echo($to1.”<br>”);
echo($subject1.”<br>”);
echo($message1.”<br>”);
echo($headers1.”<br>”);
*/

/* and now mail it */
if(@mail($recipient, $subject1, $message1, $headers1))
{
echo(“<table aligh=left><tr><td>”);
echo(“<br>”);
echo(“&#4311;&#4325;&#4309;&#4308;&#4316;&#4312; &#4332;&#4308;&#4320;&#4312;&#4314;&#4312; &#4332;&#4304;&#4320;&#4315;&#4304;&#4322;&#4308;&#4305;&#4312;&#4311; &#4306;&#4304;&#4312;&#4306;&#4310;&#4304;&#4309;&#4316;&#4304;<br>”);
echo “<meta http-equiv=”REFRESH” content=”3; url=index.php”>”;
echo(“</font></td></tr></table>”);[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@beau_kangJan 27.2009 — We are having the same problem with our company as well. I think that you need to get into contact with Google and see if you can be removed from their filters. Not sure how people get onto them though.
Copy linkTweet thisAlerts:
@NogDogJan 27.2009 — It looks like you are using the user-supplied email address as the From: header? If so, that may be viewed as a mail host relaying and suspected of being spam. The From: email address should be a valid email address on the sending domain. You could add a "Reply-To:" header with the user's email address to take care of being able to reply to them.

Ultimately, though, you can still have problems if your site is hosted on a 3rd-party hosting service which has allowed enough spam that its entire allocated range of IP addresses has been "black-listed" by some of the spam filters. In that case, I do not know how difficult it is to get an exception for your domain, or if it's easier to just move to one the hosting companies that specialize in prohibiting spam and keeping themselves from being black-listed (and probably cost more to use).
×

Success!

Help @LogicOpinion spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...