How to Install and Configure Postfix to send an email in Magento on Ubuntu

► Fanpage: / giaphugroupcom
► Subscribe to my channel: kzread.info...
► Skype: cuongnq87
► The website link: www.giaphugroup.com/magento-2...
Hi everybody, I am Cuong, Welcome back to my Magento 2 tutorial video series.
#magento #magento2 #magento2tutorial #mail #postfix #dkim #spf
In the previous lesson, I showed everybody on How to configure Magento 2 to send an email using Gmail SMTP server. If you don't watch this tutorial yet, you can watch it here bit.ly/2xQ8DVL.
Using this way to send the emails on Magento 2 website is fine. However, Gmail will limit the number of emails is sent each day, it is suitable when your website sends only a maximum of 500 emails each day. If your Magento website is a big system, 500 emails each day it doesn't enough.
To resolve the limit of emails are sent by SMTP Gmail each day. Today, I am going to show everybody on How to Install and Configure Postfix to send an email in Magento on Ubuntu.
At current, my server can not send an email.
I don't get any email after creating a customer account to succeed.
Okie, let's go.
Let's do this practice, you need to follow steps by step:
Step 1: Installing Postfix on Ubuntu.
- cat /etc/*release
I have Ubuntu 18.04 on my server.
- Installing mailtuils will install Postfix as well as a few other programs needed for Postfix to function.
apt install mailutils
Type your domain for using.
- Verify that Postfix is running on your server
1. service postfix status
I installed the Postfix to succeed.
Step 2: Configure Postfix
1. Configure Postfix to process requests to send emails only from the server on which it is running.
- nano /etc/postfix/main.cf
Change the "inet_interfaces = all" to "inet_interfaces = loopback-only"
Change the myhostname = ubuntu to myhostname = localhost
Add the mydomain = yourdomain.com
Update the mydestination to "mydestination = $myhostname, $mydomain"
2. Add your domain is pointed to your server IP address
- nano /etc/hosts
your server IP address yourdomain.com
3. Update the server name
- nano /etc/hostname
Change to yourdomain.com
- systemctl restart postfix
- Reboot the server for updating: shutdown -r now
4. Try to send an email
echo "This is the body of the email" | mail -s "This is the subject line" bestearnmoney87@gmail.com
- Check the mail logs in /var/log/mail.log
- I will try to send to another email
5. Configure TLS encryption
- nano /etc/postfix/main.cf and add the following codes:
smtp_use_tls=yes
- systemctl restart postfix
6. Try to send an email again to test TLS
echo "This is the body of the email" | mail -s "This is the subject line" bestearnmoney87@gmail.com
Yeah! TLS is working fine.
Step 3: Use an SPF Record to Prevent Spoofing & Improve E-mail Reliability
1. Go to the domain manager
2. Add the following SPF record
TXT @ "v=spf1 a mx ip4:your-server-ip-address include:yourdomain.com include:spf.protection.outlook.com include:_spf.google.com ~all"
Step 4: Install and Configure DKIM
1. apt-get install opendkim opendkim-tools
- nano /etc/postfix/main.cf and add the following codes:
Milter configuration
milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:12301
non_smtpd_milters = inet:localhost:12301
2. Generate the public and private keys
- nano /etc/default/opendkim
SOCKET="inet:12301@localhost"
- nano /etc/opendkim.conf
mkdir /etc/opendkim
- nano /etc/opendkim/TrustedHosts
127.0.0.1
localhost
192.168.0.1/24
yourdomain.com
*.yourdomain.com
- nano /etc/opendkim/SigningTable
*@yourdomain.com vietnam._domainkey.yourdomain.com
- nano /etc/opendkim/KeyTable
vietnam._domainkey.yourdomain.com yourdomain.com:vietnam:/etc/opendkim/keys/yourdomain.com/vietnam.private
mkdir /etc/opendkim/keys
cd /etc/opendkim/keys
mkdir yourdomain.com
cd yourdomain.com
opendkim-genkey -s vietnam -d yourdomain.com -b 1024
chown opendkim:opendkim vietnam.private
chown -R opendkim:opendkim /etc/opendkim/
chmod 0750 /etc/opendkim/
chmod 0750 /etc/opendkim/keys
chmod 0750 /etc/opendkim/keys/yourdomain.com
nano -$ vietnam.txt
This is the public key
Copy that key and add a TXT record to your domain's DNS entries
- nano /etc/systemd/system/multi-user.target.wants/opendkim.service
ExecStartPost=/bin/sh -c 'chown opendkim:opendkim /var/run/opendkim/opendkim.pid'
systemctl daemon-reload
service postfix restart
service opendkim restart
opendkim-testkey -s vietnam -d yourdomain.com
run this command to test the public key is added to your domain's DNS
Yeah! no issue there.
Step 5. Try to send an email again to check the result
- Go to the backend and navigate to the STORES - Configuration - GENERAL - Store Email Addresses and change all sender emails to your server email.
- Go to the frontend and try to create a new customer account.
Yeah! It works perfectly.
Thank you for your watching. If you have any questions about this practice, please feel free to leave a comment below.

Пікірлер: 4

  • @Magento2Tutorial
    @Magento2Tutorial3 жыл бұрын

    Please help me to reach 10.000 subscribers by subscribing to my channel and sharing my videos.

  • @sajidwaseemal-arfeen5144
    @sajidwaseemal-arfeen51443 жыл бұрын

    very nice Sir,

  • @markben2959
    @markben2959 Жыл бұрын

    Postal mail server is the best solution, email will be sent to inbox not spam

  • @Magento2Tutorial

    @Magento2Tutorial

    Жыл бұрын

    But this is free, and it doesn't limit the number of emails are sent each day.