I'm experiencing some issues with Ionos smtp configuration.
I use Swiftmailer with Symfony 4.
On local i receive my email using mailtrap or gmail, but on ionos's server it doesn't work with gmail or the SMTP configuration.
Here is my .env with different configs :
###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://email#gmail.com:PSW#localhost" <-- Work in local but not on Ionos
# MAILER_URL=smtp://smtp.mailtrap.io:2525?encryption=tls&auth_mode=login&username=LOGINMAILTRAP&password=PASSWORDMAILTRAP <-- Work in local and Ionos
MAILER_URL=smtp://smtp.ionos.fr:587?encryption=ssl&auth_mode=login&username=contact#mydomain.com&password=PWD <-- Doesn't work using Ionos SMTP config
###< symfony/swiftmailer-bundle ###
Here is my swiftmailer.yaml :
swiftmailer:
url: '%env(MAILER_URL)%'
spool: { type: 'memory' }
https://symfony.com/doc/current/email.html#configuration
If the username, password or host contain any character considered special in a URI (such as +, #, $, #, /, :, *, !), you must encode them. See RFC 3986 for the full list of reserved characters or use the urlencode function to encode them.
Try changing the encryption, from ssl to tls.
Here is an example:
MAILER_URL=smtp://smtp.ionos.fr:587?encryption=tls&auth_mode=login&username=contact#mydomain.com&password=PWD
And make sure to urlencode the password if it contains any special charater, as mentioned by #Fisher
Related
I´m working in a localhost server with Symfony 4 and FOSUserBundle. I can't manage to receive the email confirmation when a new user is registered.
I have tried the following post but it´s not working in my case:
Symfony 4 SwiftMailer Gmail : Email not sent
I have tried to configure SwiftMailer to send using gmail smtp server and mailtrap smtp server without success. Also I have checked dev.log and no errors are found.
I´m not sure which is the right file to configure Swift Mailer (.env or packages/dev/swiftmailer.yaml). Right now the configuration is the following:
.env file:
MAILER_URL=gmail://***#gmail.com:***#localhost
swiftmailer.yaml:
swiftmailer:
transport: gmail
username: ***#gmail.com
password: ***
host: localhost
port: 465
encryption: ssl
auth-mode: login
spool: { type: 'memory' }
stream_options:
ssl:
allow_self_signed: true
verify_peer: false
verify_peer_name: false
Any ideas? It´s not mandatory to use gmail as the smtp server.
Thanks beforehand.
SOLUTION:
The problem was in the /config/test/fos_user.yaml file:
I changed:
service:
mailer: 'fos_user.mailer.noop'
To:
service:
mailer: 'fos_user.mailer.default'
Documentation: http://symfony.com/doc/master/bundles/FOSUserBundle/emails.html
Also I have accepted less secure connections from the gmail account setting in order to work.
I had the same problem with Symfony 4. My packages version
swiftmailer/swiftmailer v6.1.0
symfony/swiftmailer-bundle v3.2.2
When I used configuration:
swiftmailer:
url: '%env(MAILER_URL)%'
spool: { type: 'memory' }
The emails were not send and no exception occurred.
Then I change the settings into:
swiftmailer:
url: '%env(MAILER_URL)%'
spool:
type: 'file'
path: '%kernel.cache_dir%/swiftmailer/spool'
And tried command:
php bin/console swiftmailer:spool:send --env=dev -vvv
And I saw the error:
[Swift_SwiftException]
No IDN encoder found (install the intl extension or the true/punycode package
So I installed true/punycode package via:
composer req true/punycode
and now emails are sending fine also with spool memory.
Default behaviour of Symfony mailer is to send the email messages immediately, but as you configured, it will "spool" the emails instead of sending them directly.
spool: { type: 'memory' }
Sending the messages from the spool is done separately, with a console command:
php bin/console swiftmailer:spool:send --env=dev
#see more docs here
UPDATE:
As #nek said on the first comment, the the memory spool send the mail immediately (if none exception occured). The spool:send command is only required when using the file spool.
I have two domains, dom1.com and dom2.com; dom1.com has IP1; the email for dom1.com are handled by google.
I need to create an email, xxx#dom2.com and redirect all emails to an email account of dom1.com ( example: yyy#dom1.com )
I 'd like to use postfix, installed on dom1.com server.
I set the MX record for dom2.com in this way:
MX mail.dom2.com
mail A IP1
so mail.dom2.com should point to IP1.
To configure postfix on dom1.com server, I did as follow:
myhostname = dom1.com
mydestination = dom1.com, dom2.com
virtual_alias_domains = hash:/etc/postfix/virtual_domains
virtual_alias_maps = hash:/etc/postfix/virtual
in virtual_domains:
dom1.com #domain
dom2.com #domain
in virtual:
xxx#dom2.com yyy#dom1.com
than I did postmap for both files and I reload postfix ... but sending email to xxx#dom2.com , I don't reveice emails on yyy#dom1.com
Where is the error?
Thanks in advance
Option what you want to use is: Catch-all
This Tutorial will help you to setup catch-all email address with postfix.
Step 1. Configure Catch-All Account
Edit /etc/postfix/virtual and configure your catch-all address like below.
# nano /etc/postfix/virtual
#example.com myuser
If you want to add exception’s in catch-all and do not want to catch-all specific accounts, Add them also in /etc/postfix/virtual file. Below configuration will send all emails to user “myuser” except emails of info#example.com and support#example.com.
#example.com myuser
info#example.com info
support#example.com support
Save /etc/postfix/virtual file and execute following command.
# postmap /etc/postfix/virtual
2. Update Postfix Configuration File
Edit Postfix configuration file /etc/postfix/main.cf and add following line at end of file.
# nano /etc/postfix/main.cf
virtual_alias_maps = hash:/etc/postfix/virtual
3. Reload Postfix Server
After changing we need to reload server to activate newly settings addedUse following command to reload postfix configuration .
# service postfix reload
I'm trying to send emails using gmail configuration but I can't.
I'm not having any errors; I also checked the symfony log files.
Nothing crashed, but no emails are sent :(
I also ran the swiftmailer:spool:send command (maybe the emails were in the spool) and as a result I received: sent 0 emails.
I'm using the dev environment, in my config_dev.yml:
swiftmailer:
transport: gmail
username: myuser#gmail.com
password: mypass
In the controller(just for test):
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('send#example.com')
->setTo('myemail#mydomain.com')
->setBody(
"some test body"
)
;
$this->get('mailer')->send($message);
Thanks in advance
UPDATE:
I switch to prod environment, same results: no errors... until i ran the command and I got this error:
[Swift_TransportException]
Connection could not be established with host smtp.gmail.com [Unable to fin
d the socket transport "ssl" - did you forget to enable it when you configu
red PHP? #50346848]
Then, I uncomment this line in the php.ini
extension=php_openssl.dll
but nothing, the same result :(
I also modified the memory to file in swiftmailer config and the email is there, in cache:
app\cache\prod\swiftmailer\spool
PS: I'm not behind any proxy
Did you check the profiler (you can know if some emails were sent, or at least spooled)? Did you try in the prod environment ?
I remember a similar issue with Swiftmailer on a dev env in a project I did. To test it, I changed spool: { type: memory } to spool: { type: file } and I checked the mails in the dev cache directory.
I'm currently trying to get Symfony2/Swiftmailer to send the contents of a submitted form via mail. My parameters.yml contains the following:
mailer_transport: sendmail
mailer_host: ~
mailer_user: ~
mailer_password: ~
Since the sendmail version on my server does not support the -bs option, which Swiftmailer seems to use by default, I have to find a way to tell Symfony2/Swiftmailer to use sendmail -t instead. Swift_Transport_SendmailTransport seems to support that, but there doesn't seem to be a corresponding configuration option for SwiftmailerBundle.
How do I tell Swiftmailer to use sendmail -t (preferrably via configuration)?
Edit 2: For now, I'm using
$message = \Swift_Message::newInstance()
[…];
$transport = $this->get('swiftmailer.mailer.default.transport.real');
if ($transport instanceof \Swift_Transport_SendmailTransport) {
$transport->setCommand('/usr/sbin/sendmail -t');
}
$this->get('mailer')->send($message);
I'm still wondering if there's a better way to do this, though.
Just spent the day on this very issue.
I prefer using straight configuration for this kind of thing, and I found this to work:
# app/config/services.yml
services:
swiftmailer.mailer.default.transport:
class: Swift_SendmailTransport
arguments: ['/usr/sbin/sendmail -t']
This configuration should work.
mailer_transport: sendmail
mailer_host: /usr/bin/sendmail # wherever your mail is
#mailer_user: ~
#mailer_password: ~
If there is still problem,
A. check who are sending mail to someone#wxy.com
1. console - check your permission to access sendmail
2. web - check web user like wwww-data can access sendmail
B. check your mail log /var/log/maillog
When Symfony Swiftmailer send,
1. mail log has not been processed, then PHP side problem.
2. else if: send to outlook
it is TLS handshake problem, it might be from outlook tls handshake.
FYI, sendmail TLS is not working with outlook well.
add next line to /etc/mail/access
Try_TLS:wxy.com NO
3. else:
Sorry, google with mail log error messages again .
I was looking for the same thing as you and i found that there is now a SendMailTransport class.
Here is the documentation : http://swiftmailer.org/docs/sending.html#using-the-sendmail-transport
I am trying to add an sslcert using netsh http from within a powershell ps1 file, but it keeps throwing errors:
$guid = [guid]::NewGuid()
netsh http add sslcert ipport=0.0.0.0:443 certhash=5758B8D8248AA8B4E91DAA46F069CC1C39ABA718 appid={$guid}
'JABnAHUAaQBkAA' is not a valid argument for this command.
The syntax supplied for this command is not valid. Check help for the correct syntax.
Usage: add sslcert [ipport=]<IP Address:port>
[certhash=]<string>
[appid=]<GUID>
[[certstorename=]<string>
[verifyclientcertrevocation=]enable|disable
[verifyrevocationwithcachedclientcertonly=]enable|disable
[usagecheck=]enable|disable
[revocationfreshnesstime=]<u-int>
[urlretrievaltimeout=]<u-int>
[sslctlidentifier=]<string>
[sslctlstorename=]<string>
[dsmapperusage=]enable|disable
[clientcertnegotiation=]enable|disable]
Parameters:
Tag Value
ipport - IP address and port for the binding.
certhash - The SHA hash of the certificate. This hash
is 20 bytes long and specified as a hex
string.
appid - GUID to identify the owning application.
certstorename - Store name for the certificate. Defaults
to MY. Certificate must be stored in the
local machine context.
verifyclientcertrevocation - Turns on/off verification of revocation
of client certificates.
verifyrevocationwithcachedclientcertonly - Turns on/off usage of
only cached client
certificate for revocation checking.
usagecheck - Turns on/off usage check. Default is enabled.
revocationfreshnesstime - Time interval to check for an updated
certificate revocation list (CRL). If this
value is 0, then the new CRL is updated
only if the previous one expires. (in
seconds)
urlretrievaltimeout - Timeout on attempt to retrieve certificate
revocation list for the remote URL.
(in milliseconds)
sslctlidentifier - List the certificate issuers that can
be trusted. This list can be a subset of
the certificate issuers that are trusted
by the machine.
sslctlstorename - Store name under LOCAL_MACHINE where
SslCtlIdentifier is stored.
dsmapperusage - Turns on/off DS mappers. Default is
disabled.
clientcertnegotiation - Turns on/off negotiation of certificate.
Default is disabled.
Remarks: adds a new SSL server certificate binding and corresponding client
certificate policies for an IP address and port.
Examples:
add sslcert ipport=1.1.1.1:443 certhash=0102030405060708090A0B0C0D0E0F1011121314 appid={00112233-4455-6677-8899
-AABBCCDDEEFF}
I might be wrong, but I believe it has something to do how I go about specifying the appid GUID in my powershell script file. Could someone please help me solve the error?
It's a problem with the way Powershell parses cmd commands.
This will execute the command successfully:
$guid = [guid]::NewGuid()
$Command = "http add sslcert ipport=0.0.0.0:443 certhash=5758B8D8248AA8B4E91DAA46F069CC1C39ABA718 appid={$guid}"
$Command | netsh
The reason for the error is that the curly braces have to be escaped each with a backtick (`).
The following command will work from the PowerShell commandline:
This will work from the PowerShell commadline:
$AppId = [Guid]::NewGuid().Guid
$Hash = "209966E2BEDA57E3DB74FD4B1E7266F43EB7B56D"
netsh http add sslcert ipport=0.0.0.0:8000 certhash=$Hash appid=`{$Guid`}
The important details are to escape each { } with a backtick (`).
If netsh raises an error 87 try appending certstorename my
There is no need to use variables. Its just for sake of convenience.
Below code will work, & here is used for invoke program with parameters, and "appid={$guid}" make it pass string value.
& netsh http add sslcert ipport=0.0.0.0:443 certhash=5758B8D8248AA8B4E91DAA46F069CC1C39ABA718 "appid={$guid}"