#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    24
    Rep Power
    0

    PHPMailer does not send email from phone or office


    Hi all.

    I'm testing the following code using the PHPMailer class, when I run the script from my house it sends me the email. But if I run the script from my iPhone or my computer at work, it does not send the email.

    My webhosting company is GoDaddy.

    I was able to receive emails when I ran this script from my phone and work computer last week, now it just stopped.

    Any idea why this is happening? Thank you in advance.

    Code:
    require("class.phpmailer.php");
    
    
    $mail = new PHPMailer();
                
                $mail->SetFrom('xxxx@mydomain.com');
    
                $mail->AddAddress('xxxx@mydomain.com');
                
                $mail->Subject = "Hello";
               
                $mail->Body = "HELLO";            
                
                $mail->Send();
     
    
    echo"Message was sent successfully";
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,500
    Rep Power
    594
    1) Please enclose your code in [ PHP ] tags not [ CODE ] tags. See the sticky at the top of this forum that says READ THIS BEFORE POSTING.

    2) What you are saying does not make much sense. The PHP code runs on the server not on the client so it does not matter if you are accessing it from a desktop or mobile device. You probably need to focus on any differences in what the respective browsers are returning to the script. You can then adjust your script to accomodate those differences.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    24
    Rep Power
    0
    Originally Posted by gw1500se
    1) Please enclose your code in [ PHP ] tags not [ CODE ] tags. See the sticky at the top of this forum that says READ THIS BEFORE POSTING.

    2) What you are saying does not make much sense. The PHP code runs on the server not on the client so it does not matter if you are accessing it from a desktop or mobile device. You probably need to focus on any differences in what the respective browsers are returning to the script. You can then adjust your script to accomodate those differences.
    Thank you for your reply. How would I go about seeing what each browser is returning to the script?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,500
    Rep Power
    594
    I'm assuming you did not post your entire script so there must be more to it. You also didn't post your form but assuming you are using the POST method, put this where you start processing the email on a submit:
    PHP Code:
    echo "<pre>";
    var_dump($_POST);
    echo 
    "</pre>"
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    24
    Rep Power
    0
    Originally Posted by gw1500se
    I'm assuming you did not post your entire script so there must be more to it. You also didn't post your form but assuming you are using the POST method, put this where you start processing the email on a submit:
    PHP Code:
    echo "<pre>";
    var_dump($_POST);
    echo 
    "</pre>"
    That is my script, it's to make sure it sends a test email, and I said when I do it from safari at home it sends it, but when I send it from safari at work it doesn't

    Here's what I did and it displayed: array(0) { }

    PHP Code:
    &#65279;require_once("class.phpmailer.php");
    echo "<pre>";
    &
    #65279;var_dump($_POST); 
    echo "</pre>";

    &
    #65279;$mail = new PHPMailer();

    &#65279; $mail->SetFrom('xxxxx@mydomain.com');

                
    $mail->AddAddress('xxxxx@mydomain.com');
                
                
    $mail->Subject "Hello";
               
                
    $mail->Body "HELLO";            
                
                
    $mail->Send(); 
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,500
    Rep Power
    594
    I guess we need to back up a bit to see how you are executing this script. Where is your form that submits it? What does the URL look like?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    24
    Rep Power
    0
    Originally Posted by gw1500se
    I guess we need to back up a bit to see how you are executing this script. Where is your form that submits it? What does the URL look like?
    There is no form, I simply type my url: http://mywebsite.com/MailTest.php

    And that sends a "Hello" subject line email to make sure it is working.

    When I type that url at home I get the email, but when I type that url at work or on my phone, I do not get the email.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,500
    Rep Power
    594
    And you get exactly the same output in all 3 places?
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    24
    Rep Power
    0
    Originally Posted by gw1500se
    And you get exactly the same output in all 3 places?
    Yes the output is the same the echo part, but it doesn't actually send out the email. Could it be the firewall or router at my office that is not allowing the email to be sent out?
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,500
    Rep Power
    594
    The email is being sent from the server. As I said, it doesn't matter where the URL comes from. The next step is to look at the mail log on the server and possibly the httpd log as well.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,997
    Rep Power
    375
    the reason it wouldnt be sending anything is:

    1.There is an error in the script
    2. required values are empty - var_dump/echo each value going into the phpMailer
    3. the SMTP settings have changed -try to look at PHPMAILER docs to change these (use something like gmail or hotmail smtp settings)
    4. for some reason the mail is not being forwarded by your hosts (they may see you are sending junk) - check logs / contact your providers
    5. check your junk/spam box where the email is being sent to

IMN logo majestic logo threadwatch logo seochat tools logo