PHP mail() is giving Network is unreachable in "Microsoft Azure VM" - php

I'm trying to test mail to send out emails from my VM at Microsoft Azure but I'm getting this errors!
Nov 3 06:33:22 devvm postfix/smtp[10942]: connect to alt1.gmail-smtp-in.l.google.com[142.250.150.27]:25: Connection timed out
Nov 3 06:33:22 devvm postfix/smtp[10942]: connect to alt1.gmail-smtp-in.l.google.com[2a00:1450:4010:c1c::1b]:25: Network is unreachable
Nov 3 06:33:22 devvm postfix/smtp[10942]: connect to alt2.gmail-smtp-in.l.google.com[2404:6800:4003:c00::1b]:25: Network is unreachable
Nov 3 06:33:22 devvm postfix/smtp[10942]: 4C7CABDD84: to=MyEmailRemoved#gmail.com>, relay=none, delay=57498, delays=57437/0.01/60/0, dsn=4.4.1, status=deferred (connect to alt2.gmail-smtp-in.l.google.com[2404:6800:4003:c00::1b]:25: Network is unreachable)
What I've tried to do is enabled port 25 from azure, but can't figure out how to fix this.

There is restriction of outbound SMTP connection from VMs. The direct SMTP connection from Azure is blocked to protect Azure data center public IP addresses from reputation abuse even if authenticated.
The Outgoing email messages that are sent directly to external domains like outlook.com and gmail.com on TCP port 25 from a virtual machine is possible only when the VM is deployed in certain subscription types.
Even for the VMs which are deployed in the Pay-as-you-go subscriptions the outbound SMTP connections on TCP port 25 are blocked. But you can remove this block if your Azure subscription is in good standing and has a sufficient payment history. You can request to have the restriction removed by going to the Cannot send email (SMTP-Port 25) section of the Diagnose and Solve blade for an Azure Virtual Network resource in the Azure portal.
Only for the virtual machines that are deployed in Enterprise Agreement subscriptions, the outbound SMTP connections on TCP port 25 will not be blocked.
As an workaround its recommended to use authenticated SMTP relay services to send email from Azure VMs. These relay services typically connect through TCP port 587. SendGrid is one such SMTP relay service, but there are others.
Read this Sending Email with Microsoft Azure document for detailed explanation on how to use SendGrid to send mails form Azure VMs.
And for more information on restriction of outbound SMTP connection from VM read this Troubleshoot outbound SMTP connectivity problems in Azure document.

Related

configure 1and1 mail on google cloud platform with laravel 5

I have setup an instance in google cloud platform. I am running laravel 5.2 project on that instance. Everything is working good but i am facing some issues while configuring 1and1 mail.
I know that google cloud platform is blocked the 587,465 and 25 port by default and we can setup some vpn which will help to remove this restriction. But i don't want to go in that way because it would have security problems.
I have tried to send email through smtp and mail driver. I am getting connection failure error through smtp driver, and through mail driver, it shows that email is sent but i am not getting the email in my inbox. Here is my .env file for mail driver settings for 1and1. I have also tried 25 port also.
MAIL_DRIVER=mail
MAIL_HOST=auth.smtp.1and1.co.uk
MAIL_PORT=587
MAIL_USERNAME=test#mydomain.com
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=tls
Can you please help me to configure it?
As you alluded to, and documented, GCE doesn't allow outbound 25, 465 or 587. This is blocking your connection to 1and1.
If you can ask 1and1 to provide an alternate SMTP port (e.g. 2525 etc) then you can use that without issue.
Google also has partners that will allow you to send up to tens of thousands of emails monthly, for free. Pick one and follow the instructions here.

Error connection mandrill (Laravel)

I have an issue with the mandrill API, I got this message :
Failed to connect to mandrillapp.com port 443: Connection timed out
It's works on my production server (ex mysite.com), but not on my dev server (ex mysite.com:8080).
The two servers have same config by the way.
Anyone knows why I got this issue ?
Thanks !
Make sure your hosting provider or internet provider (ISP) allows
outbound SMTP connections. Some shared hosting providers only allow
outbound SMTP connections on dedicated servers, while others block
them completely. In some cases, hosting providers might redirect the
connection, so instead of connecting to smtp.mandrillapp.com, you
connect to their local server instead.
Make sure the port you've selected is one that your hosting provider
or ISP has available for outbound SMTP connections. Some hosts block
all connections on port 25, for example, so you can try using a
different supported port.
Double check that you're using a valid API key to connect via SMTP,
and not the password that's used to log in to Mandrill's web
application.
If you're using Postfix, make sure that you have an SASL library
(like libsasl2 or cyrus) installed and that it's up to date.
Otherwise, you may be connecting but not passing authentication
credentials.
For other SMTP libraries, make sure you're using LOGIN or PLAIN
authentication methods.
Once you've confirmed all of the above, if you're still seeing issues,
please enable additional logging in your SMTP program or library. If
you're using an integration, contact the integration developer for
information on configuring logging of the SMTP conversation.
Where do I find my SMTP credentials?
After you create a Mandrill account, get your SMTP credentials on the
SMTP & API Info page in your account.
The SMTP password is any active API key for your account, not the
password used to log in to Mandrill. The credentials list port 587,
but any port supported by Mandrill will work, and there's no
configuration change needed within Mandrill to activate one of the
alternate ports.
Which SMTP ports can I use?
You can use port 25, 587, or 2525 if you're not encrypting the
communication between your system and Mandrill or if you want to use
the STARTTLS extension (also known as TLS encryption). SSL is
supported on port 465.
ISPs may redirect traffic on certain ports, so it's up to you which
port you use.

SMTP Traffic on port 25

What are the dangers of opening port 25 to allow smtp traffic through? I have a windows server 2003 box which has port 25 blocked (Not by ISP), I know ISP's for usually block this port from use but as I need it for some php scripts I'm running that notify users by email, Is there any dangers or precautionary actions I should take?
Any advice would be appreciated,
Thanks Luke.
If you are thinking of unblocking port 25 on outbound traffic then no, not really. If you are wanting unblock port 25 on incomming traffic to receive email from external scripts into your internal mail server then you need to ensure you have the mail server configured to prevent relaying etc.

Access Gmail's email without imap or pop3

I have a problem, i have developed a code to access Gmail's email via imap but most of online server don't allow opening of port 993 even on dedicated IP which is necessary for imap. I am confused,
How to access gmail's email without imap
What's online server mean when they say they support imap but don't allow to open port 993. How imap can be accessible without opening port 993.
Any alternate solution is appreciated.
If your hoster blocks outgoing TCP connections to port 993, I would suggest to switch the hosting provider. There's plenty of companies which offer uncrippled service.
Try IMap non ssl port 143.
imap_open( "{server.example.com:143/novalidate-cert}INBOX" , 'login' , 'password' );
Thanks

Send Mail from GMail with PHP; over proxy

I'm building an internal web-application in PHP that needs the ability to mail.
I've used the code listed here:
Send email using the GMail SMTP server from a PHP page
and it works like a charm, when I run it from my house. However, when I run the code from the office, I get the following:
Failed to connect to ssl://smtp.gmail.com:465 [SMTP: Failed to connect socket: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (code: -1, response: )]
Any idea how to get around this?
Thanks,
-JWW
I agree with the responder above - this is most likely a firewall blocking outbound connections on port 465. You can either try TLS connection on port 587 or port 25 per Gmail's troubleshooting docs : http://support.google.com/mail/bin/answer.py?hl=en&answer=78775
If you are unable to get around this (if IT will not remove the blocks for example), you could try a third party API as a proxy. Our product http://PostageApp.com can use external mailservers such as Gmail, in addition to our own MTA, and communication is all through standard http REST calls, avoiding the firewall issue.
We're a paid service but have a free plan as well...if you would be sending more email than our free plan allows for (100/day), then you'll probably fall foul of Gmail's sending limits anyway which restrict third party clients to about 100/day outbound.
http://help.postageapp.com/kb/quick-start-guides/php
Disclaimer: I work for PostageApp
It's most probably a firewall at your workplace blocking outgoing connections to port 465. Did you try port 587 instead?

Categories