SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    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

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,805
    Mentioned
    157 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';
    }
    ?>
    Are you sending from a server host or your own Localhost?

    Spike
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    Chessplayer kleineme's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by maith View Post
    I cannot find any SMPT to modify ?
    it's SMTP, maybe that's the reason?
    Never ascribe to malice,
    that which can be explained by incompetence.
    Your code should not look unmaintainable, just be that way.

  4. #4
    SitePoint Member
    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

  5. #5
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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) ?.

  6. #6
    SitePoint Member
    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,
    Paul
    Last edited by maith; May 2, 2007 at 04:16.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •