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 ?
Related
this is my first question here so bare with me.
How do I use STARTTLS with swiftmailer in php?
I am currently on Laravel 7.x running on PHP 7.3.
I need to connect to the Office365 SMTP server, which unforunately only support STARTTLS.
I cannot use another provider than Office365 due to another company infrastructure, so my options are limited.
My problem is that when i give STARTTLS as the mail encryption and attempt to connect to / send mails trough the SMTP server, I recieve the following error:
[2020-06-25 11:15:21] stage.ERROR: Connection could not be established with host smtp.office365.com :stream_socket_client(): unable to connect to starttls://smtp.office365.com:587 (Unable to find the socket transport "starttls" - did you forget to enable it when you configured PHP?) {"userId":1,"exception":"[object] (Swift_TransportException(code: 0): Connection could not be established with host smtp.office365.com :stream_socket_client(): unable to connect to starttls://smtp.office365.com:587 (Unable to find the socket transport "starttls" - did you forget to enable it when you configured PHP?) at /home/forge/censoreddomain.com/releases/20200615132510/src/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:269)
My .env config mail section:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.office365.com
MAIL_PORT=587
MAIL_USERNAME=XXXX#XXXX.se
MAIL_PASSWORD=XXXXXXXtXVF
MAIL_ENCRYPTION=starttls
Try to change "MAIL_ENCRYPTION=starttls" to "MAIL_ENCRYPTION=tls"
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
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
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.
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".