Error with user regsitration form

Archived from the Web Auction Discussion forum.

yvan — Thu Apr 02, 2009 7:19 am

Warning: mail() [function.mail]: “sendmail_from” not set in php.ini or custom “From:” header missing in D:\Inetpub\ideasdev\webauction\dataface\actions\register.php on line 455

I’m getting this error message when filling out and submitting the user registration form on my auction site. Any idea as to why this might be happening, .. or how I might go about fixing it?

The server where my website is hosted requires SMTP authentication when sending email. Is the needed smtp authentication stuff already in place in the source code? If so, .. specifically where do I specify the authentication info? Or would the existing source code need to be adapted to accommodate for this? Please advise.

Thanks!

  • Yvan

fongchun — Thu Apr 02, 2009 9:01 am

You most likely didn’t set a header. I don’t think your server would disable the sendmail_from field in the php.ini file. Remember your mail function should look like this:

Code: Select all
`$Name = “Da Duder”; //senders name
$email = “email@adress.com”; //senders e-mail adress
$recipient = “PersonWhoGetsIt@emailadress.com”; //recipient
$mail_body = “The text for the mail…”; //mail body
$subject = “Subject for reviever”; //subject
$header = “From: “. $Name . “ <” . $email . “>\r\n”; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command :)`

I just took this code from the php mail link. Note the need for the header variable and how it is sent as a parameter for the header function,


yvan — Wed Apr 22, 2009 8:13 am

Well, I already know that for certain that the server where the app lives is able to send out email (it’s Windows / IIS based).

So which file do I need to modify, .. and how, specifically? In looking at the source code for register.php (which I suspect is the file that I’d need to modify somehow) .. it’s very difficult to tell exactly where I would add the needed header info.

My header variable in register.php is defined as follows:

$headers = $this->_fireDelegateMethod(‘getRegistrationActivationEmailHeaders’, $this->form->_record, $activation_url);

if ( !PEAR::isError($headers) ) $info[‘headers’] = $headers;

Do I need to assign values in a config file somewhere else, perhaps?

BTW – Is “setting a header” a necessary part of installation/configuration for everyone? Or am I only getting this error because my server requires SMTP authentication when sending email?

Thanks,

  • Yvan

yvan — Wed Apr 22, 2009 10:17 am

Nevermind – I got it.

I remembered that with my hosting provider, the following parameters need to be added to all mail scripts to enable the smtp authentication:

ini_set(“SMTP”,”111.222.333.444”);

ini_set(“smtp_port”,”25”);

ini_set(‘sendmail_from’, ‘myemail@mydomain.com’);

I added those 3 lines to the top of my register.php file, and I am not sending and receiving email.

Question – is there some kind of global configuration file that I can move these 3 parameters to that all PHP files reference (so I don’t have to add it to each and every PHP file that sends email) ?

Thanks!

  • Yvan

fongchun — Wed Apr 22, 2009 11:29 am

That would be the php.ini file which is don’t have access to it.

What you can do is put this information in a separate file, and then just include that file into your page. So that you need to keep adding these three lines of code.


Bl4ke — Tue Jan 25, 2011 1:33 am

Can you try the php.ini file if you don’t have an access on it? I think you have to see the setting of the system you are currently using. An error occurs if it is not properly configured.