function.mail error on windows

knowledge base and frequently asked questions
Post Reply
User avatar
Brent
Site Admin
Posts: 4400
Joined: Sat Dec 12, 2009 3:35 pm
Location: Canada eh

function.mail error on windows

Post by Brent » Fri Jan 07, 2011 6:07 pm

Windows does not support sendmail similar to Unix/Linux systems. Here are some solutions for test servers on windows.

The current version of XAMPP 1.7.4 has sendmail included and it works well.
If your are not running XAMPP, you can download sendmail for windows at http://glob.com.au/sendmail/

Other solutions
These examples are for XAMPP, but other servers will be similar. Only one of the methods is required. The will not work if SMTP authentification is required on your mail server.

The best solution:
Edit xampp\php\php.ini at about line 1102 - 1105. Find

Code: Select all

SMTP = localhost

Change this line to

Code: Select all

SMTP = mail.yourmaildomain.com

This must be a valid email server you use and your computer must have internet access.

The next solution requires you to edit xampp\htdocs\yourfolder\common.php
add this line after the <?php at the top of the file.

Code: Select all

ini_set('SMTP', 'mail.yourmaildomain.com ');

This produces the same results as the first method and requires internet access.

The last solution requires editing the xampp\htdocs\yourfolder\library\mail\mail.php . Internet connection is not required.
Change line 179 from:

Code: Select all

return ($params)?mail($to, $subject, $message, $headers, $params):mail($to, $subject, $message, $headers);

To this:

Code: Select all

return ($params) ? @mail($to, $subject, $message, $headers, $params) : @mail($to, $subject, $message, $headers);

This will turn off the error reporting and allow you the proceed without errors. No mail will be sent.
You need to remember to turn on error reporting when moving to a live server to ensure mail function is working.

The other option is to turn off send mail in admin/settings under the mail tab

Post Reply