Configure Google App Engine production server with SMTP parameters - google-app-engine

My Google App Engine application needs to send out emails. On my development server, I have specified my SMTP configuration (host, port, user, password) while starting the server, and App Engine sends emails using the specified SMTP parameters.
How can I do the same with my production server?

You don't need to configure it - App Engine automatically sends email sent with the mail API using Google's own SMTP infrastructure.

Related

Accessing files on FTP server through custom VPN from app deployed on App Engine Flex: doable?

I have the following use case:
Application is deployed on App Engine Flex environment.
Application fetches data from an FTP server on API request.
FTP server can only be accessed through a custom VPN.
Can I access the FTP server from an App Engine Flex environment? If so, what would I need?
Apologies if this is not clear, I am not a network/devOps person.
As a solution, you can connect your on-premises network and application deployed to App Engine Flex via Google Cloud VPN:
Cloud VPN securely connects your peer network to your Google
Cloud (GCP) Virtual Private Cloud (VPC) network through an
IPsec VPN connection. Traffic traveling between the two
networks is encrypted by one VPN gateway, then decrypted by the other
VPN gateway. This protects your data as it travels over the internet.
You can also connect two instances of Cloud VPN to each other.
App Engine Flexible Environment is based on Google Compute Engine and consequently can connect to your remote network via Cloud VPNs. As described in the documentation Configuring your App with app.yaml, you can specify network settings in your app.yaml configuration file:
... app in App Engine is configured using an app.yaml file, that
contains CPU, memory, network and disk resources, scaling, and other
general settings including environment variables.

Cannot connect to cloud SQL [SQLSTATE[HY000] [2002] No such file or directory]

I have set up 2 projects in my Google Cloud console. The following are the two projects that I have set up in my console.
1. Cloud SQL + App Engine
2. App Engine (New)
So the idea is App Engine (1) is running the same database as App Engine (2). I have already set up the IAM Permission Page and IAM Admin and Project Page.
I have given both projects as Project Editor role too, but still my (2) still can't connect to my (1) database.
Any help please?
Granting access to an application does not automatically enable a database user account to connect to the instance.
You may connect through a proxy, in which case you should follow these steps:
Enable the API
Install the proxy client on your local machine
Determine how you will authenticate the proxy
If required by your authentication method, create a service account
Determine how you will specify your instances for the proxy
Start the proxy
Update your application to connect to Cloud SQL using the proxy
You can find related details on the Connecting to Cloud SQL from External Applications.
This documents provides steps that cover configuring access for IP connections as well.
If you connect from within the app engine environment, you may have a look at Connecting from App Engine.

When is the Google Cloud SQL API required? Some connections fail, others succeed

My Google App Engine app fails to connect to my Google Cloud SQL instance with:
java.lang.RuntimeException: The Google Cloud SQL API is not enabled for project [{project-id}]. Please use the Google Developers Console to enable it: https://console.cloud.google.com/apis/api/sqladmin/overview?project={project-id}
at com.google.cloud.sql.core.SslSocketFactory.obtainInstanceMetadata(SslSocketFactory.java:389) ~[jdbc-socket-factory-core-1.0.4.jar!/:na]
at com.google.cloud.sql.core.SslSocketFactory.fetchInstanceSslInfo(SslSocketFactory.java:284) ~[jdbc-socket-factory-core-1.0.4.jar!/:na]
at com.google.cloud.sql.core.SslSocketFactory.getInstanceSslInfo(SslSocketFactory.java:264) ~[jdbc-socket-factory-core-1.0.4.jar!/:na]
at com.google.cloud.sql.core.SslSocketFactory.createAndConfigureSocket(SslSocketFactory.java:183) ~[jdbc-socket-factory-core-1.0.4.jar!/:na]
at com.google.cloud.sql.core.SslSocketFactory.create(SslSocketFactory.java:152) ~[jdbc-socket-factory-core-1.0.4.jar!/:na]
at com.google.cloud.sql.mysql.SocketFactory.connect(SocketFactory.java:48) ~[mysql-socket-factory-1.0.4.jar!/:na]
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300) ~[mysql-connector-java-5.1.44.jar!/:5.1.44]
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2189) ~[mysql-connector-java-5.1.44.jar!/:5.1.44]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2222) ~[mysql-connector-java-5.1.44.jar!/:5.1.44]
That's strange, because I thought the API was enabled. The APIs dashboard has an entry for Google Cloud SQL with no activity and a "disable" button.
The app uses the Cloud SQL Socket Factory:
jdbc:mysql://google/{database}?socketFactory=com.google.cloud.sql.mysql.SocketFactory&cloudSqlInstance={instance connection name copied from console}&useSSL=false
When the app runs locally it connects to and updates the remote Cloud SQL instance.
The Cloud SQL instance is 2nd generation, HA, and requires SSL. All of the "gcloud sql" commands I've tried succeeded. I can interact with the database using command line tools and a local Cloud SQL Proxy.
Before I click the "Enable" button on the API I'd like to understand why the API already appears in the API dashboard (with an option to disable), and why only Cloud SQL Socket Factory connections from a Google App Engine instance fail.

AppEngine Email in Development Server

Where can we see the sent email messages in development server of Google App Engine.
You'll need to start the dev server with options to enable email to be sent. You have a few options including specifying an SMTP server or using a local sendmail if you have it running. more here..
https://developers.google.com/appengine/docs/python/tools/devserver#Using_Mail
If you don't hook up SMTP, you should see them in the logs.

GAE app access to closed server behind firewall

I have an application on google app engine servers and private master server behind firewall. Accesss to master server closed by default. So I want to open access for my GAE app. Application sends by XML-RPC requests to master server. How can I do what? How to add GAE servers to my firewall access list?
From http://code.google.com/appengine/docs/python/urlfetch/overview.html#Secure_Data_Connection:
"Your application can connect to systems behind your company's firewall using the Google Secure Data Connector (SDC). With the SDC Agent set up on your network, App Engine applications running on your Google Apps domain can authenticate with the Agent and access URLs on your intranet. The SDC Agent ensures that only your applications can connect to your intranet, and that they will do so only for users signed in using an Apps account on your domain."
If not for GAE, you could use Reverse Port Forwarding Wizard:
http://www.upredsun.com/reverse-port-forwarding/reverse-port-forwarding.html

Resources