rvdb86 Posted June 17, 2009 Share Posted June 17, 2009 Hi, I am using the PEAR mail script to send emails from a form on my website. Heres the code: require_once "Mail.php"; $from = $_POST['Name'] . " <".$_POST['Email'].">"; $to = "Recipient Address"; $subject = "Subject"; $body = "Hi,\n\nHow are you?"; $host = "Host"; $username = "Username"; $password = "Password"; $headers = array ('Content-type' => $content_type, 'From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p></p>"); } The problem is that visitors enter their name in Hebrew, therefore in the From field of the email its is printed in gibbirish. I have tried to search google for a solution and I think that I have to set the encoding to UTF8, I am just not sure how to do this exactly, or where to define it. Does anyone have any ideas? I would very much appreciate any suggestions! Link to comment https://forums.phpfreaks.com/topic/162640-need-help-with-mail-script/ Share on other sites More sharing options...
ldougherty Posted June 17, 2009 Share Posted June 17, 2009 The from field on the received message will look like whatever they input on the form itself, ie if I say Larry when you receive it the from field will say Larry. Are you saying they enter it appropriately but the form is turning it to gibberish? Link to comment https://forums.phpfreaks.com/topic/162640-need-help-with-mail-script/#findComment-858376 Share on other sites More sharing options...
rvdb86 Posted June 17, 2009 Author Share Posted June 17, 2009 That is correct. It turns their name from hebrew into gibbirish Link to comment https://forums.phpfreaks.com/topic/162640-need-help-with-mail-script/#findComment-858402 Share on other sites More sharing options...
ldougherty Posted June 17, 2009 Share Posted June 17, 2009 I believe you can specify the character set that the user can input into the form using charset http://www.w3.org/TR/html401/interact/forms.html#adef-accept-charset http://htmlhelp.com/reference/html40/values.html#charsets The other half would be in setting the charset on the mailer script itself. Link to comment https://forums.phpfreaks.com/topic/162640-need-help-with-mail-script/#findComment-858408 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.