PHP mail not working
Moderator: General Moderators
PHP mail not working
I'm using IIS server for my website. I'm not sure where to check for the setting but a form sends email, the email doesn't get to the destination. Your help is needed.
Thanks!
Thanks!
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
This is what I have in my php.ini
[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
you need to uncomment the "sendmail_from" line if you're not including the "from" header when sending mail (by default the mail() function does not).
try that first and see if you have success, I'm guessing you won't so if you don't, you need to check the settings on your smtp server (localhost apparently) and make sure that it will allow mail to be sent from php.
try that first and see if you have success, I'm guessing you won't so if you don't, you need to check the settings on your smtp server (localhost apparently) and make sure that it will allow mail to be sent from php.
Here's the code I use to send email.
The error I got is "An error occurred while sending your message."
Code: Select all
ini_set("sendmail_from",$Email);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: '".$Email."'\r\n";
if (mail($toEmailAddress, $Subject, $message, $headers)){
echo "Your message has been successfully sent.<br>";
}
else{ echo "An error occurred while sending your message.";}- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
per his php.ini he's trying to send it from the same machine that php is installed.
/me is starting to think he doesn't have a mail server set up there....[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = me@example.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK