Xoom3r Posted April 12, 2010 Share Posted April 12, 2010 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- 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 More sharing options...
TeddyKiller Posted April 12, 2010 Share Posted April 12, 2010 I've noticed you don't have a header set. "$headers" isn't defined, atleast not in the code you've given. Link to comment https://forums.phpfreaks.com/topic/198265-mail-form-encoding/#findComment-1040284 Share on other sites More sharing options...
Xoom3r Posted April 12, 2010 Author Share Posted April 12, 2010 Can you please show me what should I add to my code? Link to comment https://forums.phpfreaks.com/topic/198265-mail-form-encoding/#findComment-1040287 Share on other sites More sharing options...
Xoom3r Posted April 12, 2010 Author Share Posted April 12, 2010 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 More sharing options...
TeddyKiller Posted April 12, 2010 Share Posted April 12, 2010 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.