SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
-
Apr 26, 2007, 06:12 #1
- Join Date
- Apr 2007
- Posts
- 7
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
cannot receive email ?. How to change SMPT settings ?
Hi, I have a simple PHP programme
<?php
$to='mymail@hotmail.com';
$email='myoutlookemail@iol.ie';
$mailHeader = "From: {$email}\r\n";
$mailHeader .= "Reply-To: {$email}\r\n";
$mailHeader .= "X-Mailer: PHP/" . phpversion();
$subject='the subject';
$message='hello';
mail($to,$subject,$message,$mailHeader);
?>
I do not receive any email or any notification of failure. I have WindowsXP PHP 5.16. I have Outlook. When I open my php.ini file (I have a number of them !) I cannot find any SMPT to modify ? Should I change the SMPT settings in Outlook ?
Thanks,
Paul
-
Apr 26, 2007, 06:44 #2
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
Hi Paul and welcome to the forums
One thing you can do is run a conditional statement to see if the mail is actualy sent or not:
PHP Code:<?php
$to='mymail@hotmail.com';
$email='myoutlookemail@iol.ie';
$mailHeader = "From: {$email}\r\n";
$mailHeader .= "Reply-To: {$email}\r\n";
$mailHeader .= "X-Mailer: PHP/" . phpversion();
$subject='the subject';
$message='hello';
if(!mail($to,$subject,$message,$mailHeader)) {
echo 'Error sending Mail';
} else {
echo 'Mail Sent';
}
?>
SpikeMike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Apr 26, 2007, 07:23 #3Never ascribe to malice,
that which can be explained by incompetence.
Your code should not look unmaintainable, just be that way.
-
Apr 30, 2007, 05:56 #4
- Join Date
- Apr 2007
- Posts
- 7
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for your reply. I was lol,
as I got smtp mixed up in the php.ini file.
I have my php file on a host server which is what I want. When I run the PHP on the server, it says, "Mail Sent", but I did not receive the email ?
Also I have tested the php file from my local computer. I have modified the sendmail_from in the php.ini file to 'myoutlookemail@iol'.
The SMTP = localhost and smtp_port = 25.
I am using Xaamp and Apache. The error I get when I load the php file in my browser is:
This is the email test php file
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\xampp\htdocs\xampp\examples\testemail2.php on line 16
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\xampp\htdocs\xampp\examples\testemail2.php on line 17
Error sending Mail.
Also does the $email variable, in your code, have any purpose ?
$email='myoutlookemail@iol.ie';
Thanks,
Paul
-
Apr 30, 2007, 06:43 #5
It's not working on your local system because you don't have a SMTP server running on the port 25 of your machine (most likely, it's not there at all).
As for not getting the mail that you sent from the live server: did you check your junk folder (may be it was taken off as a spam) ?.
-
May 1, 2007, 08:52 #6
- Join Date
- Apr 2007
- Posts
- 7
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks for that. I got it working. I can receive mail to Gmail and to Outlook but not to hotmail ? It wasn't in the Junk box either, using the host server.
I have found that you must use carriage returns in order to send to hotmail.
Thanks,
PaulLast edited by maith; May 2, 2007 at 04:16.
Bookmarks