Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't this short php script send email?

Tags:

php

email

smtp

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?

like image 541
RoryG Avatar asked Jun 03 '10 20:06

RoryG


2 Answers

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.

like image 187
Tim Post Avatar answered Sep 30 '22 02:09

Tim Post


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.

like image 22
rizzletang Avatar answered Sep 30 '22 03:09

rizzletang