symfony2 + fos user bundle, register confirmation mail not receiving - email

I installed FOS UserBundle for user login/register. The thing is that after registering, it redirects me on the "../register/check-email" page where it has the well-known message that a mail with the activation link has been sent to the user's email, but I don't receive any e-mail.
My config.yml file has this code for the fos_user:
fos_user:
db_driver: orm
firewall_name: main
user_class: IngrijireMedicalaAcasa\AppBundle\Entity\User
registration:
form:
type: ingrijiremedicalaacasa_appbundle_registration
confirmation:
enabled: true
service:
mailer: fos_user.mailer.default
from_email:
address: noreply#anytext.com
sender_name: any text
Do I have to do any other configuration somewhere?
I mention I tried to change the address "noreply#anytext.com" with my own valid mail address.
I changed even the parameters.yml with my mail details but it still doesn't work.
Oh, and I try to send the mail from my localhost.
I hope you guys know what's the solving to my problem. I think it's a small thing that I don't see, I don't know or I forgot to do it.

try this : (works if your email is gmail (mailer_transport)
#app/config/config.yml
//
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
# host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: IngrijireMedicalaAcasa\AppBundle\Entity\User
registration:
confirmation:
from_email:
address: your.email#gmail.com
sender_name: Any Text
enabled: true
service:
mailer: fos_user.mailer.twig_swift
in your config_dev.yml :
//
assetic:
use_controller: true
swiftmailer:
transport: gmail
username: your.email#gmail.com
password: your password
in app/config/parameter.yml:
//
mailer_transport: gmail
//

Related

Gitlab not sending email

I've installed gitlab ce on docker with the documentation, everything is ok but mails doesn't works in gitlab (ask for new password for example).
When I test my conf in the rail-console I get the mail, when gitlab is supposed to send email, it doesn't works.
For mail I use OVH SMTP conf, my smtp_settings.yml is ok
see by yourself :
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.
if Rails.env.production?
Gitlab::Application.config.action_mailer.delivery_method = :smtp
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
authentication: :login,
address: "ssl0.ovh.net",
port: 465,
user_name: "myemail#domain.dn",
password: "mypassword",
domain: "ssl0.ovh.net",
enable_starttls_auto: true,
tls: true,
openssl_verify_mode: "peer",
ca_file: "/opt/gitlab/embedded/ssl/certs/cacert.pem",
}
end
I already tried openssl_verify_mode: "peer" and "none"
Any idea ? I'm on it from about a month.

FOSUserBundle not sending registration email

I have found a few topics related to the same issues, but the solution for them was a miss-configuration of the smtp settings.
I am using symfony 3.0 and latest FOSUserBundle. My config settings are:
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
resetting:
email:
template: email/password_resetting.email.twig
registration:
form:
type: AppBundle\Form\RegistrationType
confirmation:
enabled: true
from_email:
address: registration#site.com
sender_name: 'Our Team'
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
port: "%mailer_port%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I am able to send other emails from the same project, using the same swiftmailer settings.
I have checked the web developer tool and the email is prepared for sending
Web profiler - email area
The registration email is not received in the inbox or spam folders.
Could you let me know if I have missed anything in the configuration files that prevents the registration email from being sent?
Thanks,
Lucia
I found a solution for my problem. The registration email address had to be the same as the one used for the swiftmailer username settings. Having it set to a different email address did not work for me.

HWIOAuthBundle facebook 443 Bad Access

I'm building a symfony REST Api in which I'm trying to get HWIOAuthBundle, FOSUserBundle and LexikJWTBundle working all together.
I followed this gist for the HWIOAuthBundle/FOSUserBundle integration.
Now I'm getting the facebook login form when hitting the /login route. But after submition I get this error :
[2/2] HttpTransportException: Error while sending HTTP request
[1/2] RequestException: Failed to connect to graph.facebook.com port 443: Bad access
INFO - Matched route "hwi_oauth_service_redirect".
CRITICAL -
Uncaught PHP Exception HWI\Bundle\OAuthBundle\OAuth\Exception\HttpTransportException:
"Error while sending HTTP request"
at C:\myProject\vendor\hwi\oauth-bundle\OAuth\ResourceOwner\AbstractResourceOwner.php
line 257
DEBUG -
Notified event "kernel.request" to listener
"Symfony\Component\EventDispatcher\Debug\WrappedListener::__invoke".
...
I'm now looking for help about this. Or any other way to get those bundles to work together.
config.yml :
hwi_oauth:
# list of names of the firewalls in which this bundle is active, this setting MUST be set
firewall_names: [auth]
http_client:
timeout: 10000
verify_peer: false
max_redirects: 1000
ignore_errors: false
fosub:
username_iterations: 300
properties:
# these properties will be used/redefined later in the custom FOSUBUserProvider service.
facebook: facebook_id
# an optional setting to configure a query string parameter which can be used to redirect
# the user after authentication, e.g. /connect/facebook?_destination=/my/destination will
# redirect the user to /my/destination after facebook authenticates them. If this is not
# set then the user will be redirected to the original resource that they requested, or
# the base address if no resource was requested. This is similar to the behaviour of
# [target_path_parameter for form login](http://symfony.com/doc/2.0/cookbook/security/form_login.html).
# target_path_parameter: _destination
# an optional setting to use the HTTP REFERER header to be used in case no
# previous URL was stored in the session (i.e. no resource was requested).
# This is similar to the behaviour of
# [using the referring URL for form login](http://symfony.com/doc/2.0/cookbook/security/form_login.html#using-the-referring-url).
# use_referer: true
# here you will add one (or more) configurations for resource owners
resource_owners:
facebook:
type: facebook
client_id: {id}
client_secret: {secret}
scope: ""
infos_url: "https://graph.facebook.com/me?fields=name,email,picture.type(square)"
options:
display: popup
security.yml :
firewalls:
auth:
pattern: ^/api/minisite/user/auth
anonymous: true
stateless: true
form_login:
check_path: /api/minisite/user/auth/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
username_parameter: username
password_parameter: password
require_previous_session: false
oauth:
resource_owners:
facebook: "/api/minisite/user/auth/facebook/login/check-facebook"
login_path: /api/minisite/user/auth/facebook/login
check_path: /api/minisite/user/auth/login_check
failure_path: /api/minisite/user/auth/facebook/login
oauth_user_provider:
#this is my custom user provider, created from FOSUBUserProvider - will manage the
#automatic user registration on your site, with data from the provider (facebook. google, etc.)
service: my_user_provider
logout: true
anonymous: true
access_control:
- { path: ^/api/minisite/user/auth, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api/minisite, roles: IS_AUTHENTICATED_FULLY }
Configure this in your config.yml file.
hwi_oauth:
http_client:
verify_peer: false
Setting this allows you to turn off SSL verification.
I got the same problem using HWI on localhost. I don't know, but if it's your case, try to upload your work on a server. The reason of this issue is that your are using the port 80, but facebook need that you use the port 443 or use ipv6.
Hope this help

devise forgot password email not sending

Im trying to send a forgot password email. However the following error occurs -
Net::SMTPAuthenticationError in Devise::PasswordsController#create
535-5.7.8 Username and Password not accepted. Learn more at
I manage to see the sent email within the logs file but not within my actual inbox. Any ideas on how to fix this error?
Heres my development.rb code -
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "gmail.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: "myemail#gmail.com",
password: "mypassword"
}
Using: rails 4 and devise 3.2.3
Thanks
This error usually occurs when the associated email address is setup for 2-factor authentication. If you want to test with the same gmail account then generate an Application specific password. See details here.
If you have a another gmail account which does not require 2-factor authentication then try that one instead in your code.

Swift mail and Symfony ([Connection refused #111])

I am getting this error when I try to send an email using the Symfony framework. I had this problem a while back and rember (vaguely), that I had to change my php.ini settings and match them to my /app/config/factories.yml to get it to work.
Unfortunately, I had to rebuild my machine recently, and mail has now stopped working - and unfortunately, I can't remember what I did the last time to get ot to work.
Here is a snippet of the contents of my app/config/factories.yml file:
all:
mailer:
class: sfMailer
param:
logging: %SF_LOGGING_ENABLED%
charset: %SF_CHARSET%
delivery_strategy: realtime
transport:
class: Swift_SmtpTransport
param:
host: localhost
port: 25
encryption: ~
username: ~
password: ~
Note: The indentaion above may be wrong due to being pasted in this console - don't get side tracked by that. The YML is fine on my machine.
This is the logged error message when I try to send an email:
[19-Feb-2011 14:50:13] PHP 20. userActions->executeRegisterComplete() /lib/vendor/symfony/symfony-1.3.8/lib/action/sfActions.class.php:60
[19-Feb-2011 14:50:13] PHP 21. sfMailer->send() /path/to/actions.class.php:355
[19-Feb-2011 14:50:13] PHP 22. Swift_Mailer->send() /lib/vendor/symfony/symfony-1.3.8/lib/mailer/sfMailer.class.php:300
[19-Feb-2011 14:50:13] PHP 23. Swift_Transport_AbstractSmtpTransport->start() /lib/vendor/symfony/symfony-1.3.8/lib/vendor/swiftmailer/classes/Swift/Mailer.php:74
[19-Feb-2011 14:50:13] PHP 24. Swift_Transport_StreamBuffer->initialize() /lib/vendor/symfony/symfony-1.3.8/lib/vendor/swiftmailer/classes/Swift/Transport/AbstractSmtpTransport.php:101
[19-Feb-2011 14:50:13] PHP 25. Swift_Transport_StreamBuffer->_establishSocketConnection() /lib/vendor/symfony/symfony-1.3.8/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php:70
[19-Feb-2011 14:50:13] PHP 26. fsockopen() /lib/vendor/symfony/symfony-1.3.8/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php:233
[19-Feb-2011 14:50:13] Connection could not be established with host localhost [Connection refused #111]
I've always put like and always have worked;
I simply do not use localhost smtp service.
all:
mailer:
param:
transport:
class: Swift_SmtpTransport
param:
host: smtp.gmail.com
port: 465
encryption: ssl
username: "xxx#gmail.com"
password: xxx-password
The problem could be that you do not have disabled the mail sent in development environment. You have to complete your config_dev.yml like this:
imports:
- { resource: config.yml }
framework:
router: { resource: "%kernel.root_dir%/config/routing_dev.yml" }
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: true
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
firephp:
type: firephp
level: info
assetic:
use_controller: true
swiftmailer:
disable_delivery: true
You have to set:
disable_delivery: true (not send email)
intercept_redirects: true (if you want to see the email in your debug bar)
I had same error on my hosting provider. I have fixed it by editing factories.yml indentation. Also check your username/password values.