To enable or disable a feature per environment I'd use environmental variables, for example:
# Your .env file (Use the gem foreman
or dotenv
to get access to these in your code base
PORTAL_EMAIL_ENABLED="true"
# Controller File if ENV["PORTAL_EMAIL_ENABLED"].present? # Do logic here else # Fallback end
However for mailers in different environments, I'd recommend using:
In general - unless you have people dedicated to managing email infrastructure php native mail functionality will always cause you headaches.
Instead route emails like this through any of a number of reliable, dedicated email services.
I have had good results with mailgun. There is a list of other services you might check out here: https://mailtrap.io/blog/transactional-email-services/
Many of these will be free for low volumes of email (mailgun provides a few thousand, amazon ses free tier provides over 60000)
Your question is extremely vague which leads me to the assumption that you’ve never worked with the php mailer - the quasi standard for mailing in the realm of php. Check out this basic tutorial and Google your way from there to the specifics. Good luck!
> Also make sure you don't do something stupid like sending emails to people from your dev/staging machine.
Small hint: mailtrap. As you often want to check if your emails work and are sent in the correct place... just that they do not actually reach real people at the end.
Plus you don't need to actually send mail in order to test it. You can either use a fake external service such as Mailtrap or install a fake local server such as Papercut SMTP, FakeSMTP, smtp4dev, MailHog...
Depends on where you're hosting your app, there could be SMTP server available with your provider. For example AWS has SES (Simple Email Service).
Otherwise consider 3rd party options like SendGrid.
Another option, if you're still testing your app and its not in production yet - you can use services like mailtrap.io
A) this is not a scientific survey of google but on how the campaign's email messages. Each campaign is scored on how 'spammy' the message is. So you are blaming Gmail for the same message algorithm they use for every piece of mail and say Pete is the overall winner just means their campaign did a better job at beating the algorithm. Something you can test for with places like https://mailtrap.io/ I don't know if that is something that should be a google thing.
Download this: https://www.dropbox.com/s/q9oaijiv0x86qlj/monica.tgz?dl=0
I've updated the Dockerfile.
Changed the docker-compose for a unified .env, so that the configuration is in a single file
and separated the mysql build.
Whatever the app wants to store goes into a local dir:
./monica_data (change this in docker-compose.yml if you have to)
​
Search for jazzinabox for my comments in .env
​
To start straight away;
Copy the contents of above archive to a directory of your choice, cd in there and run docker-compose up -d
​
I configured the setup so it doesn't send mails, it logs them. If you need mails change this
MAIL_DRIVER=log
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
to
MAIl_DRIVER=smtp
and the rest to whatever your mailhost wants (same settings as in eg. thunderbird)
​
caveat:
​
If the app can't connect to the configured mailserver it fails when registering as a user and you have to reinstall. I'm to lazy to fix this right now.
​
To reinstall remove everything in ./monica_data and run
docker-compose down --rmi all -v
​
change config and run: docker-compose up -d
​
To backup the database run:
docker exec -i db-monica /bin/bash -c 'mysqldump -u${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE}' > backup.sql
​
To import that backup run:
docker exec -i db-monica /bin/bash -c 'mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} $
{MYSQL_DATABASE}' < backup.sql
​
That should be it, if your NAS hasn't other problems.
​
​
​
​
Is PHP Mail configured correctly? https://www.quackit.com/php/tutorial/php_mail_configuration.cfm
That's the main reason PHP Mail doesn't work the most times.
Maybe the SMTP server is configured to send emails only at internal email addresses. Had this case once and wasted a lot of time debugging it :D
If PHP and the mailserver is configured correctly and the mails are sent, but don't reach your mailbox, it's also possible that the mailserver is blacklisted. https://mxtoolbox.com is a great tool for debugging that.
Beside that, I recommend https://mailtrap.io (a fake SMTP for viewing emails without sending real mails) for testing. Setting up your own fake SMTP is a bit of a hassle.