nsForum logo

Welcome Guest ( Log In )

 
Reply to this topicStart new topic
> Connecting To Gmail Using Smtp Via Php Script
mdRafn
post Nov 19 2014, 05:47 PM
Post #1





Group: Verified NS Member
Posts: 6
Joined: 22-April 13
Member No.: 20,628



~hi all,

I have tried just about everything, and Googled until I've run out of answers...
I am trying to connect to my GMail account via php script to send emails (as NS continually keeps getting blacklisted on shared hosting).

I have tried using GMail application specific authentication, Captcha unlocking, and just about everything else I could find on stackoverflow. I have tried php mail() and swiftmailer. I keep getting a connection timeout. I am wondering if something set at NS is preventing connection to a remote server?

Here is my Swiftmailer snippet:
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465,'ssl')
->setUsername('myname@gmail.com')
->setPassword('mypassword');
$transport->start();
echo 'Transport started = '.$transport->isStarted();

with this message after about 20 secs...
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection timed out #110]'

So--my question is, is it possible to connect to GMail via smtp from shared hosting at NS? If so, how?

tia
_mark
Go to the top of the page
 
+Quote Post
Craig
post Nov 20 2014, 03:43 AM
Post #2





Group: Administrators
Posts: 988
Joined: 23-June 08
From: Pennsylvania
Member No.: 1,317



QUOTE (mdRafn @ Nov 19 2014, 05:47 PM) *
~hi all,

I have tried just about everything, and Googled until I've run out of answers...
I am trying to connect to my GMail account via php script to send emails (as NS continually keeps getting blacklisted on shared hosting).

I have tried using GMail application specific authentication, Captcha unlocking, and just about everything else I could find on stackoverflow. I have tried php mail() and swiftmailer. I keep getting a connection timeout. I am wondering if something set at NS is preventing connection to a remote server?

Here is my Swiftmailer snippet:
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465,'ssl')
->setUsername('myname@gmail.com')
->setPassword('mypassword');
$transport->start();
echo 'Transport started = '.$transport->isStarted();

with this message after about 20 secs...
Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp.gmail.com [Connection timed out #110]'

So--my question is, is it possible to connect to GMail via smtp from shared hosting at NS? If so, how?

tia
_mark

The hosting firewall blocks connections on ports other than 80 and 443, so it won't work.
Go to the top of the page
 
+Quote Post
dmgatwork
post Dec 13 2014, 07:30 PM
Post #3





Group: Verified NS Member
Posts: 21
Joined: 30-August 10
Member No.: 10,968



QUOTE (Craig @ Nov 20 2014, 04:43 AM) *
The hosting firewall blocks connections on ports other than 80 and 443, so it won't work.


So what is the way you can send SMTP emails from a php script? Is there a how to available, I have tried on several occasions to do the same but have not been able to. Thanks Don
Go to the top of the page
 
+Quote Post
Craig
post Dec 14 2014, 10:09 PM
Post #4





Group: Administrators
Posts: 988
Joined: 23-June 08
From: Pennsylvania
Member No.: 1,317



QUOTE (dmgatwork @ Dec 13 2014, 07:30 PM) *
So what is the way you can send SMTP emails from a php script? Is there a how to available, I have tried on several occasions to do the same but have not been able to. Thanks Don

You can't SMTP to an external server. Normally you would just use PHP mail function or Pear mail modules with the default settings. You can also try using "localhost" as the SMTP server with no login info.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
Tags
No Tag inserted yet

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version    Network Solutions © 2011 Time is now: 25th April 2017 - 07:06 AM
Domain Names | Web Hosting | Web Design | Shopping Cart Software | Online Marketing | SSL Certificates