Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Warning: mail(): SAFE MODE Restriction in effect. 1

Status
Not open for further replies.

tnsbuff

Technical User
Jan 23, 2002
216
0
0
US
Hi,

I'm having a problem with sending html mail from a form. I get an error:

Warning: mail(): SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE.

The 5th parameter is $mailheaders.

This is the related code:


Code:
$mailheaders = "MIME-Version: 1.0\n";
$mailheaders .= "Content-type: text/html; charset=iso-8859-1";
mail($to,$subject,$body,$tfrom,$mailheaders);

I've searched high and low, but can't seem to come up with the right fix.

Can anyone help?

Thanks,
 
Well first you are missing the 1st header or the "From Header" at the beginning,
($headers = "From: \"Me\"<me@here.com>\n";)
that makes it a malformed header.

There should only be 4 args...

$headers = "From: \"Me\"<me@here.com>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
mail('myAddress@hotmail.com', 'Email with attachment from PHP', $message, $headers);


Not sure if you are interested but you should look at the pear module for mail, makes life so much easier. here is a snippet for that package.


<?
include("Mail.php");

$recipients = "mail_to@domain.mail";

$headers["From"] = "mail_from@domain.mail";
$headers["To"] = "mail_to@domain.mail";
$headers["Subject"] = "Test message";

$body = "TEST MESSAGE!!!";

$params["host"] = "smtp.server";
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = "user";
$params["password"] = "password";

// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);

$mail_object->send($recipients, $headers, $body);
?>





 
Hi,

Thanks for the reply.

Actually the variable $tfrom was the From parameter. This is a script that someone else wrote that I'm trying to troubleshoot.

Anyway, I added the $tfrom variable to the $mailheaders (cutting it down to 4 parameters) and now it works, except I'm getting this: MIME-Version: 1.0
. . . on the same line as my subject. How can I get rid of that?

Here's the relevant part of my code:

Code:
$tfrom = "From: {$nameVar}<$emailVar>";
$mailheaders = " MIME-Version: 1.0\n";
$mailheaders .= "Content-type: text/html; charset=iso-8859-1\n";
$mailheaders .= "$tfrom \n";
mail($to,$subject,$body,$mailheaders)

Thanks for your help.
 
Try this...

$tfrom = "From: {$nameVar}<$emailVar>\r\n";
$mailheaders = " MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/html; charset=iso-8859-1\r\n";
$mailheaders .= "$tfrom \r\n";
mail($to,$subject,$body,$mailheaders)
 
Thanks willyd61, but I just figured it out. I had a space at the beginning right before MIME-Version: 1.0\n

Once I removed that, the subject line didn't have the MIME-Version in it.

Thanks very much for taking a look though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top