A
A
Alisa2020-11-29 13:48:20
Email
Alisa, 2020-11-29 13:48:20

How to send mail from localhost while testing a site?

Делаю сайт на opencart 3, локальный сервер использую AMPPS под MAC OS. И проблема в том, что при оформлении заказа, регистрации нового пользователя и подобных действиях на email не проходит ни каких сообщений.
Почту пробовала разную Yandex. Google, Mail.ru.
Читала много и том, что почтовые сервисы с недоверием смотрят на почту приходящую с локального хоста, но как сделать чтобы все же заработало так и не поняла. Подскажите как мне добиться желаемого в рамках перечисленных технологий?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Алиса, 2020-11-29
@ blonde_13

Всем спасибо! Нашла такое решение!
How to send emails from localhost (MAC OS X El Capitan)
Sometimes we may need to send mails from localhost for testing purposes. That can be easily done using an external Mail client (Gmail, Hotmail, Yahoo… ETC) and Postfix, which is the standard email server installed by default in Mac OS X (At least in the latest versions). As I said, this is a quick workaround for testing purposes but if security is a requirement, you must buy yourself a certificate at Thawte or Verisign, or create your own one.
This tutorial is about how to configure Postfix for Mac OS X. If you are using windows, you may want to try this approach.
Step 1. Edit Postfix config file
Open a terminal and edit the file main.cf
sudo vi /etc/postfix/main.cf
First check Postfix is configured correctly, look for the following lines (They are probably separated):

mydomain_fallback = localhost
mail_owner = _postfix
setgid_group = _postdrop

Now add the following lines at the very end of the file:
#Gmail SMTP
relayhost=smtp.gmail.com:587
# Enable SASL authentication in the Postfix SMTP client.
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options=noanonymous
smtp_sasl_mechanism_filter=plain
# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom

This is telling Postfix to use a GMAIL SMTP server with Simple Authentication and Security Layer (SASL). Which will be stored in the path “/etc/postfix/sasl_passwd“. You can use any other SMTP provider (Hotmail, Yahoo, ETC…). You only need to know the SMTP host and port. For example for hotmail you should replace the relayhost for the following:
#Hotmail SMTP
relayhost=smtp.live.com:587
Or for Yahoo:
#Yahoo SMTP
relayhost=smtp.mail.yahoo.com:465
Step 2. Create the sasl_passwd file
We need to create the sasl_passwd file with the SMTP credentials
sudo vi /etc/postfix/sasl_passwd
Write the following content and save:
smtp.gmail.com:587 [email protected]:your_password

Create the Postfix lookup table from the sasl_passwd file.
sudo postmap /etc/postfix/sasl_passwd
This will create the file sasl_passwd.db
Step 3. Restart Postfix
To apply all new changes we have to restart Postfix:
sudo postfix reload
Step 4. Turn on less secure apps (Only Gmail)
In Gmail we must switch on the option “Access for less secure apps“, otherwise we will get the error:
SASL authentication failed
Step 5. Test it!
Let’s send a mail to our own account to be sure everything is working fine:
date | mail -s testing [email protected]
You can check the mail queue and the posible delivery errors using “mailq“
mailq
Use the postfix logs to ensure everything is working as expected:
tail -f /var/log/mail.log
Other useful commands
To clear the mail queue:
sudo postsuper -d ALL

V
Vladimir Kohan, 2020-11-29
@SkazochNick

Put MAMP. In the Postfix section you configure and everything works fine

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question