Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    PHP mail being delivered to wrong address

    Hi guys,

    I have a script to send emails that works perfectly from my local testing server.

    When I uploaded it to the server the site is hosted on the emails are then not delivered correctly.

    Im developing the system from my company where we all have an email address under the same domain ie: im 'me@testcompany.com' and the boss is 'boss@testcompany.com'.

    When I use the script to send myself an email it ends up in the bosses inbox and not mine!!

    Script works perfectly fine if im sending an email to my hotmail address.

    Its odd because the exact same email generated from my local testing server (using ISP's SMTP) correctly delivers the email to my address, and not the bosses!!

    Any ideas where I should start hunting for issues?

    Cheers

  • #2
    met
    met is offline
    Regular Coder
    Join Date
    Oct 2009
    Location
    United Kingdom
    Posts
    728
    Thanks
    4
    Thanked 119 Times in 119 Posts
    haven't had much experience using SMTP from localhost but you'll probably need to provide some code in order to get any advice

    does this problem only occur with this mail script?

  • #3
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Heres the code

    Works perfectly well to other email address, just when its going to my work address gets routed to the boss instead

    PHP Code:
    <?php
     
    require_once('phpmailer/class.phpmailer.php');
    //include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
     
    $mail             = new PHPMailer();
     
    $body             file_get_contents('mailtest.html');
    $body             eregi_replace("[\]",'',$body);
     
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->Host       "localhost"// SMTP server
    $mail->SMTPDebug  2;                     // enables SMTP debug information (for testing)
                                               // 1 = errors and messages
                                               // 2 = messages only
     
    $mail->SetFrom('me@testcompany.co.uk''me');
     
    $mail->AddReplyTo('me@testcompany.co.uk''me');
     
    $mail->Subject    "MailTest SMTP";
     
    $mail->AltBody    "To view the message, please use an HTML compatible email viewer!"// optional, comment out and test
     
    $mail->MsgHTML($body);
     
    $address "me@testcompany.co.uk"";
    $mail->AddAddress($address, "
    me");
     
     
    if(!$mail->Send()) {
      echo "
    Mailer Error" . $mail->ErrorInfo;
    } else {
      echo "
    Message sent!";
    }
     
    ?>

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    Quote Originally Posted by boydt98 View Post
    PHP Code:
    $address "me@testcompany.co.uk""; 
    You have a typo at this line. There should be only 1 double quote at the end. Is this a typo in your post only or you have a typo like this in the real script too ?

    Edit: I guess it is in the post only since you said it worked ... Have you deployed exactly the same script locally and at the server ?

    Just in case: Could it be that you have different $address when you test the script locally and at the server ? At some hosts the incoming mail could be configured to deliver all e-mails with not existing in the system e-mail address to some particular e-mail (like mail@testcompany.co.uk). I would check the e-mail address $address for typos very carefully while testing ...
    Last edited by SKDevelopment; 10-13-2009 at 09:58 AM.


  •  

    Tags for this Thread

    Posting Permissions

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