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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 29

Thread: mail problem

  1. #1
    Regular Coder
    Join Date
    May 2010
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mail problem

    So I tried using swiftmailer, and php mailer. I have an email add xxx@xxx.com, when I use its user name and password with outlook it works. But when I upload an email script(using cpanel) at xxx.com,using swiftmailer or phpmailer with the same user name/password,and I run it, I get authentication failure. Now this xxx@xxx.com is created on another mail server, we can name it mail.aaa.com. If I create xxx@xxx.com(by cpanel) at xxx.com(xxx@xxx.com already exist at mail.aaa.com)and uses its login details, swiftmailer/php mailer will work. But the problem with that,when the script is run it will be emailed on mail.xxx.com mail.aaa.com should be the one receiving the email. How can I address this issue?

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Post the code you use to do this, removing private info such as passwords and whatnot. Also, make sure you are using a proper username for it, some webhosts use different formats, such as a "+" instead of a "@".
    If I've helped you out, show your appreciation by clicking the "Thanks" link as well as a link below!

    AdFly
    Facebook | Twitter
    Google | YouTube

  • #3
    Regular Coder
    Join Date
    May 2010
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dubz View Post
    Post the code you use to do this, removing private info such as passwords and whatnot. Also, make sure you are using a proper username for it, some webhosts use different formats, such as a "+" instead of a "@".
    Here is the code. This username/password/port 25 works with ms outlook. But does not work when uploaded on a host/mywebsite by cpanel. Also in my ms outlook connection, I don't use ssl/tsl encryption connection.
    <?php
    require_once 'swiftmailer/lib/swift_required.php';

    // Create the mail transport configuration
    //$transport = Swift_MailTransport::newInstance();

    $transport = Swift_SmtpTransport::newInstance("mail.xxx.com", 25);
    $transport->setUsername("username@xxx.com");
    $transport->setPassword("password");

    // Create the message
    $message = Swift_Message::newInstance();
    $message->setTo(array(
    "xxx@xxx.com" => "Aurelio De Rosa",
    "xxx8@xxx.com" => "Audero"
    ));
    $message->setSubject("This email is sent using Swift Mailer");
    $message->setBody("You're our best client ever.");
    $message->setFrom("account@bank.com", "Your bank");

    // Send the email
    $mailer = Swift_Mailer::newInstance($transport);
    $mailer->send($message);

    ?>
    Error message

    Fatal error: Uncaught exception 'Swift_TransportException' with message 'Failed to authenticate on SMTP server with username "username@xxx.com" using 2 possible authenticators' in /home/xxx/public_html/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php:184 Stack trace: #0 /home/kite/public_html/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(312): Swift_Transport_Esmtp_AuthHandler->afterEhlo(Object(Swift_SmtpTransport)) #1 /home/xxx/public_html/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(120): Swift_Transport_EsmtpTransport->_doHeloCommand() #2 /home/xxx/public_html/swiftmailer/lib/classes/Swift/Mailer.php(80): Swift_Transport_AbstractSmtpTransport->start() #3 /home/kite/public_html/send3.php(23): Swift_Mailer->send(Object(Swift_Message)) #4 {main} thrown in /home/xxx/public_html/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php on line
    Last edited by Anishgiri; 05-14-2014 at 09:30 AM.

  • #4
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Check the credentials and server address/port, the script seems fine otherwise.
    If I've helped you out, show your appreciation by clicking the "Thanks" link as well as a link below!

    AdFly
    Facebook | Twitter
    Google | YouTube

  • #5
    Regular Coder
    Join Date
    May 2010
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dubz View Post
    Check the credentials and server address/port, the script seems fine otherwise.
    Checker the port? I used port 25 in ms outlook together with the username/password, and it works fine?

  • #6
    Regular Coder
    Join Date
    May 2010
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dubz View Post
    Check the credentials and server address/port, the script seems fine otherwise.
    Check the port? I used port (smtp)25 in ms outlook(under the advance settings) together with the username/password, and it works fine. Sorry for being naive, but how can I check the credentials/server address port?
    Last edited by Anishgiri; 05-14-2014 at 10:07 AM.

  • #7
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    I'm not sure what's going on, it should work from what I hear. Try running a script via SSH and see what errors are outputted that way is another thing to try. Otherwise, verify the information you're using is correct with the web server. It could be a typo with the password or a misconfiguration with it. If your password has any special characters, try one without them (just alphanumeric) and see if that works. I don't know what else to say otherwise.
    If I've helped you out, show your appreciation by clicking the "Thanks" link as well as a link below!

    AdFly
    Facebook | Twitter
    Google | YouTube

  • #8
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,310
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Sounds to me like the mail server may have blocked the IP range of your web server.

    If it works via outlook but not using this code then there are two reasons:
    1) Your code is faulty (I'm assuming you've tried it using a wamp package on your computer?)
    2) The web server is not making a successful connection because the login is wrong or the machine is blocked by the mail server.

    The latter part of 2 sounds most likely.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #9
    Regular Coder
    Join Date
    May 2010
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post
    Sounds to me like the mail server may have blocked the IP range of your web server.

    If it works via outlook but not using this code then there are two reasons:
    1) Your code is faulty (I'm assuming you've tried it using a wamp package on your computer?)
    2) The web server is not making a successful connection because the login is wrong or the machine is blocked by the mail server.

    The latter part of 2 sounds most likely.
    Thanks for the answer. I think the login is not wrong cause it works with outlook. If the machine is blocked by the mail server, how can I solve the problem? Thanks. I have not yet tried it on wamp.
    Last edited by Anishgiri; 05-16-2014 at 03:00 AM.

  • #10
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Are you running on a web host or your own VPS/dedi server? Try the WAMP/XAMPP as well so you can see if it works for you since it wouldn't be blacklisted. If the web server is the same as the mail server I don't think it would be blocked, if anything it would be one of the last ones to be blocked.
    If I've helped you out, show your appreciation by clicking the "Thanks" link as well as a link below!

    AdFly
    Facebook | Twitter
    Google | YouTube

  • #11
    Regular Coder
    Join Date
    May 2010
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dubz View Post
    Are you running on a web host or your own VPS/dedi server? Try the WAMP/XAMPP as well so you can see if it works for you since it wouldn't be blacklisted. If the web server is the same as the mail server I don't think it would be blocked, if anything it would be one of the last ones to be blocked.
    So I tried to run my script on localhost/wamp, and it works, sending email. So what this show? Thanks.

  • #12
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    It shows there's an issue with connecting from your web server to your mail server. Is it the same? If so try using 'localhost' to connect to. If not, check the firewall settings and see if either your web server is blocked or you need to add it to be allowed.
    If I've helped you out, show your appreciation by clicking the "Thanks" link as well as a link below!

    AdFly
    Facebook | Twitter
    Google | YouTube

  • #13
    Regular Coder
    Join Date
    May 2010
    Posts
    208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dubz View Post
    It shows there's an issue with connecting from your web server to your mail server. Is it the same? If so try using 'localhost' to connect to. If not, check the firewall settings and see if either your web server is blocked or you need to add it to be allowed.
    I already tried connecting with my localhost using the same username/password and mailer server, and it connects and send email.
    Last edited by Anishgiri; 05-16-2014 at 08:51 AM.

  • #14
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    If your webserver is the same as your mail server then upload your script and connect to 'localhost'. I didn't say to connect to you, I said to connect to 'localhost', meaning the machines self. I never said yours.
    If I've helped you out, show your appreciation by clicking the "Thanks" link as well as a link below!

    AdFly
    Facebook | Twitter
    Google | YouTube

  • #15
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,310
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Quote Originally Posted by Dubz View Post
    If your webserver is the same as your mail server then upload your script and connect to 'localhost'. I didn't say to connect to you, I said to connect to 'localhost', meaning the machines self. I never said yours.
    This.

    If you use a server ip address or domain in your script and the mail server is on the same machine the odds are that it won't make a successful connection. You need to change the address to 'localhost' or '127.0.0.1' (both are the same thing however the IP is probably better just in case the machine doesn't lookup it's own localhost).

    I have a hunch however that you may be looking to connect to another mail server such as your ISP? If thats the case then they often don't accept mail from external connections and as such you will simply not be able to make this connection unless you know the CEO of the ISP who will authorise it.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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