Check emails locally with mamp

Firstly, I am completely unfamiliar with this localhost server installation, and I spent the last couple of days trying to figure it out, but no luck.

I am developing a php site with an email form.

I use MAC using codekit and MAMP FREE and everything works fine. Now my question is: can I check the email that should be sent from the form locally?

I tried many examples, for example, uncommented the [mail function] bit in the php.ini , installing a third-party application, such as fakeSMTP and MockSMTP , but absolutely nothing worked. The mailto() code should work, because when I debug it, the error does not occur

Can this be done or not? Anyone who knows how to properly configure this or what might point me to a dead end guide?

+6
source share
1 answer

Well, if someone is interested in this, I finally found a way to make it work.

I will explain it here in a detailed walkthrough.

Requirements

  • MAMP pro
  • when working with a gmail account, you really need to log into your email inbox (I did this using gmail, not sure about others)

Walkthrough

  • First of all, you need to install mamp pro. On the postfix tab, add gmail.com as the domain for outgoing emails, and then click "Use this data"
  • After that, you want to open the terminal and enter sudo nano /System/Library/LaunchDaemons/org.postfix.master.plist (this will allow you to edit the org.postfix.master.plist file, otherwise it cannot be edited.

  • The only editing you want to do is add at the top, right after the <dict> , this line <key>Disabled</key>

  • Now close the terminal and restart your Mac.

  • After restarting, open MAMP and go to the website on which you want to check emails and send an email.

Note. It is important that you use a work account for the to section of the mail() function, otherwise you will not be able to check emails!

  • Nothing happens in the interface, but if you now open the MAMP → postFix tab, at the bottom you can see the path to the log file and arrow, click on the arrow and display the log message.
  • Scroll down to the last line where you should find something by saying status:sent . This sent status means that the message was sent and that the local test worked as expected

What's next?

  • Ok, now log in to your gmail account (the one you used for the to section in your mail() function
  • Go to spam and you will see the email you just sent from your local machine.

I use it and it really works beautifully.

Quick tip

After that, I made a couple of settings in my gmail inbox, adding an alias and a filter. I am going to explain this, as it may be useful for beginners

  • Log in to your gmail account from your PC
  • go to the top right cog icon and then go to settings
  • In the accounts and import, add another account to use as an alias (in my case it is [myemailaddress] +test@gmail.com )
  • Once this is done, go to the filters tab
  • Add a new filter and configure it to affect all emails on [myemailaddress] +test@gmail.com
  • Click Continue to go to the next screen.
  • Now here you can configure it as you prefer, but it is important to check that you never send it to spam, so that you can always see the emails that you would like to test. . (my personal setting is to skip the inbox (archive) and add a specific label).

What is it! hope this is clear enough and that it will help some of you.

+8
source

Source: https://habr.com/ru/post/988440/


All Articles