I am using xampp 1.7.4 (PHP 5.3.5) and when i send emails to my email address its working. and even i used mail server as examples its not working. below is the code.
<?php
ini_set("SMTP","mail.sweetinteractive.com");
$suc = mail("uzair@sweetinteractive.com","Learning PHP","Messag开发者_开发技巧e is not working ","From: uzair@sweetinteractive.com");
if($suc){
echo "Mail sent";
} else {
echo "Mail sending Failed.";
}
?>
And even i tried out working with our mail server. But its showing and error
Warning: mail() [function.mail]: SMTP server response: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1) in C:\xampp\htdocs\LearnPhp\email1.php on line 3
You seem to be missing the closing quote on the "From:" header.
Please configure your php.ini and sendmail.ini files in xampp folder.
First : need to change the fields in php.ini (rootdrive:\xampp\php\php.ini)
(Note : semicolon ';' signifies a comments in ini files)
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = mail.sweetinteractive.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = uzair@sweetinteractive.com
second step : change the sendmail.ini file (rootdirectory:\xampp\sendmail\sendmail.ini)
note : remove semicolon (;) form give below fields and make changes in sendmail.ini file
smtp_server=mail.sweetinteractive.com
; smtp port (normally 25)
smtp_port=25
auth_username=uzair@sweetinteractive.com
auth_password=give your password here without any quotes
I believe this should gonna work. Because you are not providing any authentication parameters in previous post.
Note : after making the changes in php.ini and sendmail.ini files, stop the apache service from Xampp control panel and run it again.
and your php code
<?php
ini_set("SMTP","mail.sweetinteractive.com");
$suc = mail("uzair@sweetinteractive.com","Learning PHP","Message sending will work now","From: uzair@sweetinteractive.com");
if($suc){
echo "Mail sent";
} else {
echo "Mail sending Failed.";
}
?>
Your system has to send a so-called fully qualified domain name, see https://www.rfc-editor.org/rfc/rfc2821#section-4.1.1.1
This is most likely an anti-spam protection setting in your mailserver - it prevents "normal" client machines from sending in mail directly, a tactic that often is used by malware.
Make sure the SMTP in your php.ini is correct, and appropriate it to your mail server.
You have two options:
Change you system's host name to an FQDN (a bit extreme for this operation and may not even be possible in your setup, depending on many factors), or use PEAR::Mail or similar approach that allows you to specify the name used in the HELO/EHLO.
精彩评论