Reputation: 865
After creating a Wordpress template using Lightsail, no email can be sent from the site.
Upvotes: 0
Views: 698
Reputation: 1945
If you've used the WordPress-specific package in Lightsail to create your site, you should be able to send email just by adding in an SMTP plugin and connecting it to either a transactional email service like SendGrid or Postmark, or connecting it to an existing SMTP server via username and password.
In my experience, I've not found it necessary to open up ports or anything server-level when using the WordPress Lightsail image.
For the plugin, personally, I love FluentSMTP for this as it makes things simple, gives you lots of features, and it's free ;)
The route I usually go is then to create a free SendGrid account, add your sending domain to it, and then you have to verify it by adding a few records to your DNS zone for the domain.
https://docs.sendgrid.com/ui/account-and-settings/how-to-set-up-domain-authentication
Once all that's complete, generate an API key from SendGrid and enter it into FluentSMTP's settings:
https://fluentsmtp.com/docs/set-up-the-sendgrid-driver-in-fluent-smtp/
Should be good to go at that point!
Upvotes: 0
Reputation: 865
There are few reasons and you need to solve all of them before an email can be sent from AWS Lightsail Wordpress template.
sudo apt-get install sendmail
to install sendmail. After this step, you can see sendmail in /usr/sbin
/var/log/mail.log
. Reason: your domain name matches either your server’s hostname or a setting in sendmail’s config file. Solution: Configure sendmail to force send emails to your actual mail server instead of itself by editing /etc/mail/sendmail.mc
and add the following lines:define(`MAIL_HUB', `domain.com.')dnl
define(`LOCAL_RELAY', `domain.com.')dnl
Make sure to (1) change your own domain name (2) ended with the trailing dot! Reference and credit to: https://tecadmin.net/sendmail-user-unknown-error-resolved/
sudo sendmailconfig
to configure sendmail with the updated setting and press ‘Y’ for all default when prompted/opt/bitnami/php/etc/php.ini
by enabling sendmail_path: env -i /usr/sbin/sendmail -t -i
. Remember to remove the prefix ";" in the beginning of the line./etc/hosts
, e.g. 127.0.0.1 localhost myhostname
sudo /opt/bitnami/ctlscript.sh restart
sudo /opt/bitnami/ctlscript.sh restart php-fpm
Upvotes: 2