Page 1 of 1

[SOLVED] PHP mail funtion error

Posted: Fri Feb 04, 2005 10:01 am
by ljCharlie
The code below used to work under PHP 4.0 and that we upgrade to PHP 5, it' no longer working. Will anyone suggest where the problem is and how to fix it?

Code: Select all

$To = "myEmail@myDomain.com";
			$message ='
					<html>
					<body>
					<p><strong>The person '.$txtNmLast.', '.$txtNmFirst.' has successfully updated his/her online profile on '.$updateTime.'.</strong></p>					
				<table width="900" height="361" border="1" cellpadding="0" cellspacing="0">
				  	<tr> 
					    <td width="130" bgcolor="#333366"><strong><font color="#FFFFFF">dirID:</font></strong></td>
					    <td width="130" bgcolor="#FF9933">'.$txtID.'</td>
					    <td width="130" bgcolor="#333366"><strong><font color="#FFFFFF">Hide Status:</font></strong></td>
					    <td width="250" bgcolor="#FF9900">'.$hdStatus.'</td>
					    <td width="130" bgcolor="#333366"><strong><font color="#FFFFFF">Last Name:</font></strong></td>
					    <td width="130" bgcolor="#FF9900">'.$txtNmLast.'</td>
					  </tr>
					  <tr> 
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">First Name:</font></strong></td>
					    <td bgcolor="#FF9933">'.$txtNmFirst.'</td>
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">Maiden Name:</font></strong></td>
					    <td bgcolor="#FF9900">'.$txtMdnName.'</td>
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">Middle Name:</font></strong></td>
					    <td bgcolor="#FF9900">'.$txtMdlName.'</td>
					  </tr>
					  <tr> 
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">Nick Name:</font></strong></td>
					    <td bgcolor="#FF9933">'.$txtNckName.'</td>
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">First Major:</font></strong></td>
					    <td bgcolor="#FF9900">'.$txtFstMajor.'</td>
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">First Class Off:</font></strong></td>
					    <td bgcolor="#FF9900">'.$txtFstYear.'</td>
					  </tr>
					  <tr> 
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">First Degree:</font></strong></td>
					    <td bgcolor="#FF9933">'.$txtFstDegree.'</td>
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">Second Major:</font></strong></td>
					    <td bgcolor="#FF9900">'.$txtSndMajor.'</td>	
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">Second Class Off:</font></strong></td>
					    <td bgcolor="#FF9900">'.$txtSndYear.'</td>
					  </tr>
					  <tr> 
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">Second Degree:</font></strong></td>
					    <td bgcolor="#FF9933">'.$txtSndDegree.'</td>
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">Email:</font></strong></td>
					    <td bgcolor="#FF9900">'.$txtEmailAddrs.'</td>
					    <td bgcolor="#333366"><strong><font color="#FFFFFF">Web Site:</font></strong></td>
					    <td bgcolor="#FF9900">'.$txtWebsiteAddrs.'</td>
					  </tr>
					</table>
					</body>
					</html>';
			$headers  = "MIME-Version: 1.0\r\n";
			$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
			//$headers .= "From: Retrieval Page"." <".$txtEmailAddrs.">\r\n";
			$headers .= "From: '".$txtEmailAddrs."'\r\n";
			$subject = "My profile update";
			mail($To, $subject, $message, $headers);
The error is:

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in F:\wwwroot\home\alumni\updateSuccess.php on line 264

Thank you,

ljCharlie

Posted: Fri Feb 04, 2005 10:11 am
by feyd
did you forget to change the php.ini to reflect the proper sendmail_from ?

Posted: Fri Feb 04, 2005 10:14 am
by ljCharlie
Thank you for the response. Where do I change the php.ini file and usuasly where is that file located? I'm not the web server administrator. Is this something the web server administrator has to do?

ljCharlie

Posted: Fri Feb 04, 2005 10:21 am
by feyd
Windows Servers require having several smtp settings set in the php.ini typically.. The ini is located somewhere in the system paths. Use phpinfo() to determin where the current php.ini is being loaded from.

Posted: Fri Feb 04, 2005 11:06 am
by ljCharlie
So another word, who ever is the web administrator can make changes to this php.ini file, correct? I can not do anything if I'm only a user, right?

ljCharlie

Posted: Fri Feb 04, 2005 11:11 am
by feyd
sendmail_from and SMTP are both settable from php code with ini_set().

Posted: Fri Feb 04, 2005 12:18 pm
by ljCharlie
Glad to hear that. So how do I set it, where on the file, and which file do I set it? This is the location, http://www.uwstout.edu/foundation/phpinfo.php. It showed me a bunch of information. I'm not sure what to look for.

ljCharlie

Posted: Fri Feb 04, 2005 12:24 pm
by feyd
fifth line: Configuration File (php.ini) Path E:/php/php.ini

provided you have access rights to that place on the server, and you can restart your web server, you can change them in that file.. however, if you want to change them via the script, then running ini_set() with the appropriate arguments, as detailed on that page, will yield much the same results..

Posted: Fri Feb 04, 2005 1:03 pm
by ljCharlie
Well, that's what I'm afraid you're going to say. I saw this line Configuration File (php.ini) Path E:/php/php.ini too but I don't have rights or permission to that file.

So if I'm going to ask the administrator to do so, what do I need to tell me to do?

ljCharlie

Posted: Fri Feb 04, 2005 2:42 pm
by feyd
just head down the ini_set() route..

Posted: Mon Feb 07, 2005 10:13 am
by ljCharlie
Many thanks for the response. Since I have no permission to edit the php.ini file and we don't want to set mails sent via PHP from just one particular email address, I was told to use this line ini_set('sendmail_from','you@yourdomain.com'); before the mail() function was called. I have no errors by using this method but I did not receive the email. Any idea why?

ljCharlie

Posted: Mon Feb 07, 2005 10:18 am
by feyd
there are many factors to not recieving an email.. were you expecting the email to show at the address you specified in the sendmail_from setting? It won't get sent there unless you tell the mail function to copy that address in some fashion: to, cc, or bcc.

Posted: Mon Feb 07, 2005 11:19 am
by ljCharlie
Many thanks for all your support. I got it working now. I specified a different address in the $to variable and that is why I didn't receive any emails. It's working now.

ljCharlie

Same problem

Posted: Wed Feb 23, 2005 12:16 pm
by parallon
Hey there all. I have the same error:

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in c:\Inetpub\wwwroot\WebWorks\demo\pre_demo.php on line 662

The only thing that i did was to upgrade from PHP 4.3.10 to 5.0.3 by replacing the necessary .dll files. I have tried changing the php.ini file (just in case there is a difference betweent the two versions), but the only thing that gets it to work is by calling the php4ts.dll in IIS. Once I point it to the php5ts.dll it quits working again.

BTW - Server is XP Pro running IIS

Thanks in advance,

Parallon

Posted: Wed Feb 23, 2005 12:52 pm
by feyd
very likely, it's the same issue.. walk through the thread.. properly update php.. not just the DLL's everything needs to be updated.