mail() - "sendmail_from" not set in php.ini
I am trying to use the mail() function. However get this error on execution:
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in E:\domains\n\mywebsite.co.uk\user\htdocs\test.php on line 1
I am currently using fasthosts as my web hosting service. Because of this i can't access the php.ini file to make the necessary changes.
Is there any other way of doing this?
Thanks in advance.
as the error message says, just add a From: header and pass it to the mail function:
mail('firstname.lastname@example.org', 'Subject', 'Hello foo!', "From:email@example.com\r\n");
Hi, Thanks for your response. But when i run it with From header i get this error:
Warning: mail() [function.mail]: SMTP server response: 554 <firstname.lastname@example.org>: Recipient address rejected: Relay access denied in E:\domains\n\mywebsite.co.uk\user\htdocs\test.php on line 3
Any ideas what's causing this?
Most likely your mail server is not set up correctly for your current needs. It seems like the mail script is not authenticating properly. You'll either need to configure your smtp server or else use a different one (both of which I believe are out of the scope of PHP's mail function but don't quote me on that as I use the PEAR Mail class instead - which incidentally would probably help you out if you dont want to muck about with your local mail server).
how to set the SMTP server in php...
i get this warnin when i try to send mail
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\xampp\htdocs\pro_php\register.php on line 60
Users Browsing this Thread
There are currently 2 users browsing this thread. (0 members and 2 guests)