I can't seem to get my php script to send email.
<?php
echo "Does this page work?";
mail('my email address', 'test subject', 'test message');
?>
First, I have set the mail function settings in the php.ini file as follows:
I checked my email account settings on outlook. It does not require authentication, its port is 25, and its type of encrypted connection is 'Auto'. Given this I configured my php.ini file accordingly:
SMTP = ssl://smtp1.iis.com
smtp_port = 25
Then I set:
sendmail_from = my email address
The echo statement prints out in the browser, so I know the php file is recognized and processed. But the browser also shows the following error:
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\mailtest.php on line 3
I have clearly set the sendmail_from so I don't know what else to do. I have also tried removing the 'ssl://' part from the SMTP setting in the php.ini file, and configuring the php5.ini file. Which of these .ini files should I be configuring anyways?
You did uncomment sendmail_from
in php.ini
, yes? It should look like this:
; For Win32 only.
sendmail_from = [email protected]
Not like this:
; For Win32 only.
;sendmail_from = [email protected]
The only reason for PHP to say its not set .. is, well, if it's not set.
Edit
The only other issue that I could think of (for that warning) is that you may be editing the wrong php.ini file. If it's actually set , PHP should not be issuing that warning. I believe the default PHP configuration on your platform is \xampp\php\php.ini
Edit2
Your SMTP host may be using something called pop-before-smtp
. Try this using another mail provider that does use SMTP (password) authentication to rule that out.
To answer your question about 'which of these .ini files should I be configuring' you can run phpinfo() to see your server's configuration. That will list the paths to all of your config files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With