Test emails locally with mamp

后端 未结 1 1460
野性不改
野性不改 2020-12-29 00:10

First thing first, i\'m totally new to this kind of localhost server setup and i\'ve been spending the last couple of days trying to figure this out, but with no luck.

1条回答
  •  南方客
    南方客 (楼主)
    2020-12-29 00:41

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

    I'm gonna explain it here in a detailed step-to-step tutorial.

    Requirements

    • MAMP pro
    • working gmail account cause you actually need to login to the email account inbox (I made it work using gmail, not sure about others)

    Step-by-step tutorial

    • First thing first, you need to install mamp pro. In the postfix tab, add gmail.com as domain for outgoing emails and then click the button "Use this data"
    • After this is done, you want to open the terminal and type in sudo nano /System/Library/LaunchDaemons/org.postfix.master.plist (this will allow you to edit the org.postfix.master.plist file otherwise not editable.

    • The only edit that you want to do is adding at the top, right after , this line Disabled

    • Now close the terminal and restart your mac.

    • After the restart, open MAMP and go to the website you want to test the emails and submit the email.

    NB: It is important that you use a working account for the to section of the mail() function, otherwise you won't be able to test the emails!

    • Nothing happens in the front end, but if you now open MAMP -> postFix tab, at the botto you can see the path of the log file and an arrow, click on the arrow and it will display a log message.
    • Scroll down till the last line, where you should find something saying status:sent. This status sent means that the email has been sent and that the local test worked as expected

    What's next?

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

    I'm using it, and it is actually working nicely.

    Quick tip

    After this, I made a couple of adjustment in my gmail inbox, adding an alias and a filter. I'm gonna explain this as well as it may be useful for a beginner

    • Login to you gmail account from your pc
    • go to the top right cog icon and then go to settings
    • In accounts and import, add another account to use as alias (in my case is [myemailaddress]+test@gmail.com)
    • Once this is done, go to filters tab
    • Add a new filter and set it up to affect all the emails to [myemailaddress]+test@gmail.com
    • Click continue to go to the next screen
    • Now, here you can actually tweak it as you prefer, but the important thing is to check never send it to spam so that you will always be able to see the emails that you'd like to test. (my personal setup is to skip the inbox (archive) and add a specific label)

    That's it! hope this is clear enough and that it will help some of you.

    0 讨论(0)
提交回复
热议问题