Send mail thanks to the smtp service of ionos host (1and1) - php

I have a website hosted by ionos (before it was named 1and1). This website uses the symfony 4 framework. Everything is working properly except for sending emails. I have configure my .env file like this:
MAILER_URL=smtp://contact#mysite.com:password#smtp.ionos.fr:465
But this is not working, and I get this error:
Exception occurred while flushing email queue: Connection could not be established with host smtp.ionos.fr [Connection timed out #110]
I have already tried with the 587 port (TLS), without success. Moreover, I have tried encoding the first # used for the username with %40 to avoid conflict. I think the issue might come from the SMTP configuration.

For those who are struggling, even after reading this:
https://www.ionos.com/help/email-office/general-topics/settings-for-your-email-programs-imap-pop3/
I used the configuration below (with the port 25), and it works!
MAILER_URL=smtp://smtp.ionos.fr:25?auth_mode=login&username=emailAddress&password=myPassword

Related

Swiftmailer localhost

I would like to send mail with symfony swiftmailer in localhost.
I have put this line in my .env file :
MAILER_URL=smtp://localhost:25
And I have the error :
Exception occurred while flushing email queue: Connection could not be established with host localhost :stream_socket_client(): unable to connect to localhost:25 (Connection refused)
Could you tell what do I have to do to send mail correctly ? (I don't want to use Gmail)
use MAILER_URL=null://localhost
or you need to install and configure a local smtp server
Ok, I have understood.
Currently, I have to put the username and password in plain text in the .env file.
Is there a possibility to get the username and password at the runtime and store them in the ram instead of storing them in plain text in the .env file ?

Having trouble to send email in live server using laravel 5.1

Hi I setup a contact form for my website with following configuration using Laravel framework
MAIL_DRIVER=smtp
MAIL_HOST=smtp.netregistry.net
MAIL_PORT=465
MAIL_USERNAME= example#domain.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=ssl
MAIL_FROM= example#domain.com
MAIL_NAME= name
the above config works fine in my localhost, however when I tried in live server it gives me error
Connection could not be established with host smtp.netregistry.net [Connection refused #111]
I tried to fix it by changing mail server to smtp.gmail.com and even tried port 25, 465, 587 for encryption such as ssl, tls, startTLS none of them worked.
So I contacted hosting providers and asked for help and after 12 days of my struggle to get them address my issue finally come up with
our cloud infrastructure does not allow external smtp connections from our hosting. This means that if you are sending emails from your website you will need to use localhost as the smtp host setting.
so now I tried to change my MAIL_HOST to localhost which gave me error
Connection could not be established with host smtp.netregistry.net [Connection refused #0]
and now they were suggesting something wrong with my script. Any suggestions
That is complete BS from your host. First thing, it's common for cloud systems to block OUTGOING SMTP, as it's a spam prevention measure, but your script is fine. Your host may be blocking everything but port 80, which means you can't connect to an SMTP host at all. You may be able to use localhost by not using SMTP at all, and use the builtin mailer(sendmail is common).
Change MAIL_DRIVER=smtp to MAIL_DRIVER=mail to use php's built in mailer. This may solve your problem, if not, then you should seek other hosting arrangements.

Server return error Unable to connect SMTP server when use ssl

Hi guis I have been migrating an application to new server, is an Ubuntu server but on the new server I have some problem to send emails using Cakephp 2.0.
If the host on cake mail config is localhost I have the following error:
SMTP Error: 530 5.7.0 Must issue a STARTTLS command first
Search on the internet the solutions may be is config SMTP ssl://mydomain.com.br on php.ini or using ssl host like this ssl://mydomain.com.br on cake mail config. On the first option nothing change, error persist and with host ssl on cake mail config I have the following error:
Unable to connect to SMTP server.
I make a simples test using only php mail() function and the email is been sent.
On this server I config postfix and dovecot may be this can be the problem?
you can use 'PHPMailer'.
it's simple and easy.
https://github.com/PHPMailer/PHPMailer

Swiftmailer raise an exception with code 554, client host rejected

I'm using Swiftmailer to send mail through a contact form with Symfony. My ISP allows me to send mail from a remote server with my mail account information (username, password and smtp).
My problem is that when I'm sending a mail from my development site (from my desktop server) I can do it and the mail is sent, but in the production environment Swiftmailer raise an exception saying that the client host is rejected (code 554 5.7.1) and failed to send the mail. I have tried to debug this with the app/console swiftmailer:email:send and I get the same error :
Exception occurred while flushing email queue:
Expected response code 220 but got code "554",
with message "554 5.7.1 <unknown[here-example-ipv6]:49545>:
Client host rejected: Access denied " [] []
The ipv6 (here-example-ipv6) is corresponding to a dns of my host that I have not configured, but I don't understand why Swiftmailer believes that this ip is corresponding to the client host, my configuration seems (app/config/config.yml and parameters.yml) to be good because that's work fine from my desktop. Any help would be appreciated, thank.
Ok, I get it. I was confused with the error message because I thought it was comming from Switmailler, but it was comming from my ISP mail server.
The problem was that when you want to send a mail from a remote location my ISP require to activate SSL encryption.
So I have added two more parameters for the Swfitmailler configuration :
port: 465
encryption: ssl
and now that's fine. But because I was testing from a production environment, the cache has to be cleared in order the changes to take effect.

Swiftmailer SMTP transport rejecting local IP address

I'm trying to send an email using the Swift_SmtpTransport but I'm getting the following error:
501 5.5.2 <[::1]>: Helo command rejected: invalid ip address
The SMTP server is a remote server and it works from my production server, but not from my development machine, which is running OS X.
It also doesn't bother to throw an exception, instead it required me to use a logger plugin to find out why it wasn't working.
What can I do to make it use a real IP address?
I did some poking around in the code and found it.
When configuring the SMTP transport, you need to call setLocalDomain(). Using PHP on OS X, this defaults to "::1", which is rejected by the remote server. I've just added a line in my development configuration to set that:
$transport = Swift_SmtpTransport::newInstance('mail.pantsburger.com', 587);
if (SITE_ENV == SITE_ENV_DEV) {
$transport->setLocalDomain('[127.0.0.1]');
}
I think this is also a bug with Swiftmailer - it really should be throwing an exception for something like this, rather than just listing each recipient as "failed".

Categories