Jump to content

mail form encoding


Xoom3r

Recommended Posts

Hey there people, I  have a problem with the mail() function.

 

When I receive mails with it, it's all giberish.

 

(Note that I need to receive mails in hebrew and I need my mails encoded UTF-8)

 

here's my code:

 

<?php
$first = $_GET['first'];
$last = $_GET['last'];
$comp = $_GET['company'];
$phon = $_GET['phone'];
$cell = $_GET['cell'];
$email = $_GET['email'];
$mesg = $_GET['mesg'];

if(strlen($first) < 1)
{
print "FIRST NAME";
print " IS EMPTY";
print "<br><br>";
}
if(strlen($last) < 1)
{
print "LAST NAME";
print " IS EMPTY";
print "<br><br>";
}
if(strlen($comp) < 1)
{
print "COMPANY";
print " IS EMPTY";
print "<br><br>";
}
if(strlen($phon) < 1)
{
print "COMPANY PHONE";
print " IS EMPTY";
print "<br><br>";
}
if(strlen($cell) < 1)
{
print "PERSONAL PHONE";
print " IS EMPTY";
print "<br><br>";
}
if(strlen($email) < 1)
{
print "EMAIL";
print " IS EMPTY";
print "<br><br>";
}
if(strlen($mesg) < 1)
{
print "MESSAGE";
print " IS EMPTY";
print "<br><br>";
}
else
{
$to = "[email protected]";
$subject = $comp;
$message = $first . " " . $last . "\n" . $comp . "\n" . $phon . " " . $cell . "\n\n" . $mesg;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
}
?> 

Link to comment
https://forums.phpfreaks.com/topic/198265-mail-form-encoding/
Share on other sites

Alright I figured it out, added headers to my code, but now, it shows me this error:

 

Notice: Undefined variable: headers in C:\wamp\www\gtfo\post.php on line 56

 

Warning: mail() [function.mail]: SMTP server response: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1) in C:\wamp\www\gtfo\post.php on line 58

Mail Sent.

Link to comment
https://forums.phpfreaks.com/topic/198265-mail-form-encoding/#findComment-1040289
Share on other sites

This is a typical UTF-8 mail header.

You would place this ABOVE the mail() line.

$headers = 'MIME-Version: 1.0' . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'From: Yourname <' . $from . ">\n";

 

Replace "Yourname" with the name in which the email is sent by etc, and "$from" for the from-email.

I dont think this allows 'Hebrew' I dont know what Hebrew is.. but anyway, thats a header for UTF-8 :)

Link to comment
https://forums.phpfreaks.com/topic/198265-mail-form-encoding/#findComment-1040290
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.