skip to Main Content

I am new to PHP and I am trying to build a form that will be used to send emails. The form has two inputs, one is for user email and the other is for the message. Once the user clicks on submit button an email is supposed to be sent to me.

I saw the PHP mail() function but I am not able to use it because I am on a local server that is MAMP and I am using Mac OS 11.4v,
PHP version: 7.4.12 ,
Apache Port: 80 (I don’t know if this information will help but still I will provide it in case it does)

I saw various ways on the web to solve this problem but every solution is kind of different I am don’t know what is right at this point. I know there are some changes to be made in the files of the MAMP folder but I don’t know what are the steps and what will work.

Can anybody please help me out? Thanks in advance!

2

Answers


  1. Chosen as BEST ANSWER

    I used the PHP mailer library and it worked.

    Here is the link for the library: https://github.com/PHPMailer/PHPMailer/tree/5.2-stable

    Go for the stable version of the library which is 5.2-stable. The instructions to use the library are provided in this GitHub link.

    Remember you need a Gmail account from which you will be sending emails. You have to provide an ID and password for the same in the library. Also, you need to make this Gmail account less secure. Just search on google:- 'less secure apps' and you will find the link to make your account less secure.

    For reference:- check out this youtube video:- youtube.com/watch?v=0luMSSesJBA


  2. I’ve used a 3rd party SMTP service to send emails from local instances. I use Sendgrid since it’s free for their lowest plan. The drawback is that you’d need to build the API integration with Sendgrid, so it’s more work on that front.

    I’ve also used Mailhog to intercept emails locally.

    If you are developing WordPress locally, then the Sendgrid integration is ultra easy – just download the Sendgrid integration plugin.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search