Jump to content

Need help with mail script


rvdb86

Recommended Posts

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

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.

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.