Add User Emails in WSO2 EMM 1.1.0 not working - php

I am testing WSO2 EMM 1.1.0 on a Ubuntu. When you add a new user an invitation email should go to the user. The email settings can be defined in the configuration page. I have used the followings config for email
Host: smtp.gmail.com
Port: 587
Username: email#gmail.com
Password: something
Sender Email Address: email#gmail.com
I have used port 587 because in the code tls is mentioned while sending the email. I have tried the same with port 25 also.
var sender = new email.Sender(String(emailConfigurations.SMTP[0]), String(emailConfigurations.Port[0]), String(emailConfigurations.UserName[0]), String(emailConfigurations.Password[0]), "tls");
Now when I create a user, I get an error saying 'Fatal error occured!'. The moment I delete the Email configs, the error goes away.
The code in ../repository/deployment/server/jaggeryapps/emm/client/js/users/add.js at line#90 defines this error.
500: function() {
n.setText('Fatal error occured!');
n.setType('error');
n.setTimeout(1000);
},
Any ideas how to resolve this error?

Related

php showing message sent but didn't receive it to my email

So my smtp php mailer is showing that the message was successfully sent but in reality it's not. I am now using email from the same domain that Synchro suggested because I was using gmail please have a look here and had issues with it and php mailer was showing error but after switching to mail from the same domain actually it is showing sent but I am not receiving any email.
So I went to my email logs and found this.
Event: failure error
User: eightysh
Domain: eighty6.shop
From Address: baltajiwissam#gmail.com
Sender: no-reply#eighty6.shop
Sent Time: May 21, 2022, 9:34:09 AM
Sender Host: www.eighty6.shop
Sender IP: 185.93.244.110
Authentication: dovecot_login
Spam Score:
Recipient: baltajiwissam#gmail.com
Delivery User: -system-
Delivery Domain:
Delivered To:
Router: remoteserver_route
Transport: mailchannels_smtp
Out Time: May 21, 2022, 9:34:09 AM
ID: 1nsIgk-0000C6-Im
Delivery Host: smtp.mailchannels.net
Delivery IP: 52.25.134.49
Size: 1.54 KB
Result: ECDHE-RSA-AES256-GCM-SHA384:256 CV=yes: SMTP error from remote mail server after end
of data: 550 5.7.1 [BFD] Sender prohibited by SPF
i did few research about Sender prohibited by SPF but i didn't get it :/ am i suppose to add my pc ip address to the host ?? if yes its not logical cause its gonna be a public form please help
It's not quite clear what you're doing, but at a guess it looks like you are sending from a gmail address without sending through a gmail server, and that will always fail SPF checks, because google doesn't allow that. It's nothing to do with the submitter's address, but the email server that you send the message through – if it's not smtp.gmail.com, then you can't use a gmail address as your from address.

Eden mail php imap connection failure

I try to get the Gmail inbox emails using Eden mail PHP from my localhost (XAMPP Apache server). But it throws a fatal error:
Fatal error: Uncaught Eden\Mail\Exception: Problem connecting to
ssl://imap.gmail.com:993. Check server, port or ssl settings for your
email server.
in C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php:357
Stack trace:
0 C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php(170): Eden\Core\Exception::i()
1 C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php(357): Eden\Mail\Imap->connect()
2 C:\xampp\htdocs\edenMail\index.php(36): Eden\Mail\Imap->getMailboxes()
3 {main}
thrown in C:\xampp\htdocs\edenMail\vendor\eden\mail\src\Imap.php on line 357
I have used below code in Eden mail's index.php file with my own credentials.
$imap = eden('mail')->imap(
'imap.gmail.com',
'myEmailId',
'myPassword',
993,
true);
In addition to that, I have enabled IMAP/POP3 and turned on less secure apps as well in my Gmail settings.
I have encountered this error only when I try to connect from my localhost (Windows-Xampp-Apache server). But there is no error if test code in my web server working in Linux environment.
Could anyone please help me to connect the google imap.gmail.com to retrieve inbox emails?
I have followed the instructions given in the below link and got the issue resolved. I am sharing it as if may help anyone with the same issue.
https://www.hesk.com/knowledgebase/?article=72
Having problems getting Gmail to work with HESK? Try these settings.
» Email sending
To send emails using Gmail server enter these details:
SMTP Host: smtp.gmail.com
SMTP Port: 587
SSL Protocol: OFF
TLS Protocol: ON
SMTP Username: (your Gmail username)
SMTP Password: (your Gmail password)
Also make sure your "From email address" in HESK settings is set to your Gmail email address!
Still no luck? Check with your host if they have port 587 blocked in firewall.
» POP3 fetching
To fetch mail from Gmail server enter these details:
POP3 Host: pop.gmail.com
POP3 Port: 995
TLS Protocol: ON
POP3 Username: (your Gmail username)
POP3 Password: (your Gmail password)
Important: make 100% sure that "POP3 download" in your Gmail settings
is set to "Enable POP for mail that arrives from now on". If not,
Gmail will send all existing (even read) messages to HESK when it
first connects.
» IMAP fetching
To fetch mail using IMAP from Gmail server enter these details:
POP3 Host: imap.gmail.com
POP3 Port: 993
Encryption: SSL
POP3 Username: (your Gmail username)
POP3 Password: (your Gmail password)
» Error messages
Connection timed out
Required ports are probably blocked on your server's firewall. Ask your host to configure the firewall to allow TCP connections on ports 587, 995 and/or 993.
Some hosting companies will not do that due to their policies. In that case you will need to, in order to integrate Gmail with HESK, find another host or try the HESK cloud.
Permission denied
Try logging with your google account here to unlock it for application access.
Click the "Continue" button to Allow access to your Google account.
Password error: [AUTH] Username and password not accepted. Too many
login failures
Your username and/or password is not correct, double-check them ad remember passwords are CaSe SeNSiTiVe!
Password error: [AUTH] Web login required
See this article
Error: 0 could not connect to the host "pop.gmail.com"
This could mean that:
required ports are blocked on your server's firewall. Ask your host to unblock TCP connections on ports 587, 995 and/or 993
- OR -
SSL certificate verification fails on your server. Try this:
download this file
save it somewhere to your server, for example to C:\wamp\ssl\cacert.pem
open your php.ini file
find the line
;openssl.cafile=
and change it to the location of the cacert.pem file while also removing the starting ;
openssl.cafile=C:\wamp\ssl\cacert.pem
save and restart the server
test again

Connection could not be established with host smtp.gmail.com

Trying to send email with Swiftmailer, I got this error. I've configured swiftmailer with:
transport: smtp
host: smtp.gmail.com
username: example#example.com
password: password
port: 587
encryption: ssl
I always get this error message:
Connection could not be established with host smtp.gmail.com
I've also tried with:
transport: gmail
host: smtp.gmail.com
username: example#example.com
password: password
port: 587
encryption: ssl
The complete error message is
[YYYY-mm-dd hh:ii:ss] app.ERROR: Exception occurred while flushing email queue: Connection could not be established with host smtp.gmail.com [ #0]
Other questions:
My case is different from this. In my case I've not Avast antivirus.
EDIT: changing port to 465, as Alex Howansky suggested, erro changes in
Exception occurred while flushing email queue: Failed to authenticate on SMTP server with username "my email address" using 1 possible authenticators
1: Either you must allow less secure apps or use app password by enabling 2 step verification on your gmail acc.
2: Disable any antivirus on your machine(this is something no one will tell u but is necessary in many cases).
3: Don't forget to clear your cache (sometimes it don't take updated content from .env file)
4: You don't need to change anything in Mailer inside config directory(not recommended), you should use env variables
it's looking for the server smtp.gmail.com but isn't able to resolve it. use this domain smtp.gmail.com and port 25 or 465.

Trying to send emails with Symfony 2 using SwiftMailer : Connection could not be established with host smtp.gmail.com [ #0]

Here's a description of my environment first, since it's a bit particular :
I use a Windows 8.1 PC combined with a virtual machine running with Vagrant. It's basically a Debian 64bits machine.
This VM is in fact my server.
Then, I use Symfony 2 for my project and I'm trying to use SwiftMailer with gmail (using my own gmail adress) in order to send emails thanks to a contact form (email address of the user, name of the user and content of the mail).
My action fills the email data with the ones given in the form and sends the mail.
Btw, it checks if the data is valid by using the ->isValid() method.
My problem comes after I submit the form, I receive an Exception from SwiftMailer : Connection could not be established with host smtp.gmail.com [ #0]
Here's my config_dev.yml :
swiftmailer:
transport: gmail
username: "%gmail_user%"
password: "%gmail_password%"
delivery_address: "%gmail_user%"
encryption: ssl
host: smtp.gmail.com
port: 465
auth_mode: login
The "%gmail_user%" and stuff is defined in a parameters.yml file. Here's the content :
parameters:
mailer_transport: gmail
mailer_user: null
mailer_password: null
gmail_user: my_gmail_address#gmail.com
gmail_password: my_gmail_passwd
After a lot of search through the whole Internet, I've tried many things from here or from elsewhere, and nothing did work : Using tls, trying port 587, trying with the IP of the smtp.gmail.com server gave me the same error.
The SSL extension seems to be enabled too :
php --info | grep openssl
OpenSSL support => enabled
and some other stuff that tells the version of OpenSSL.
I checked my IMAP settings and the general setting that enables or disables applications to access to my gmail, it is enabled.
I also tried to telnet smtp.google.com 465 and it worked fine since I reached to connect.
I just don't know what to do now. I hope some of you had the same issue and can help me.
Have a nice day !
Edit : Problem solved and a new one appeared
After further investigation, I randomly tried to change the config_dev.yml file that way :
transport: mail
This solved my problem with the SwiftMailerException, though the mail doesn't come to the delivery_address email address even if I change it to another address I own (an hotmail one).
I'll work on it, but I hope my solution can help.
Edit #2 : Tried to solve the sending problem but nothing worked.
This is going to be a book..
I tried to add a spool system by adding this in the config.yml :
spool: {type: memory }
The mail seem to be sent since the profiler tells me he sent it.
I added this to my controller to send all the mails that could be spooled :
$spool = $transport->getSpool();
$sent = $spool->flushQueue($this->container->get('swiftmailer.transport.real'));
I also added this to check if it's really sent :
if ($this->mailer->send($message)) {
echo '[SWIFTMAILER] sent email to ' . $toEmail;
} else {
echo '[SWIFTMAILER] not sending email: ' . $mailLogger->dump();
}
I am really lost and don't know what to do..
Here's the code that send the mail in the controller :
$message = \Swift_Message::newInstance()
->setSubject("The subject from the form")
->setFrom("The address from the form")
->setTo("The address which comes from an entity")
->setBody("The body from the form made with a twig template");
$mailer = $this->container->get('mailer');
$mailLogger = new \Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($mailLogger));
if ($mailer->send($message)) {
echo 'sent email';
} else {
echo 'not sending email: ' . $mailLogger->dump();
}
This always tells me 'sent email', but I never receive it.
Did you try to make a connection with cURL? I had something similar with elasticsearch (elastica), apparently it used a cURL HTTP proxy I didn't know about because it was configured in php.ini.
off-topic: You can also try if mailcatcher works for your needs.
I had the same error (Connection could not be established with host smtp.gmail.com [ #0]) and the reason was in antivirus (Avast!). When I disabled it error has gone.
I found the solution and never answered here but since this question has like 2000+ views I feel like it's important.
So, everything was fine and the only thing I didn't know about was that during development (aka when in dev environment), swiftmailer seems to disable delivery, as told here :
http://symfony.com/doc/current/email/dev_environment.html#disabling-sending
All I had to do was to set this in config_dev.yml and config_test.yml files :
swiftmailer:
disable_delivery: false
Just be careful to which address your mails go. For example, on this project, it would have sent dummy mails to our clients which would have been quite problematic.
To prevent this, you can do what's told in the symfony documentation (http://symfony.com/doc/2.8/email/dev_environment.html#sending-to-a-specified-address-es)
# app/config/config_dev.yml
swiftmailer:
delivery_addresses: ['dev#example.com']

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.

Categories