PHP mail form with SMTP authentication

You can use this form, where SMTP authentication is required. If you have server details with an email address and password, that you have provided time of creating of email address. Before proceeds these information are required; like: Domain name, Server or Host name, SMTP/Outgoing server name and SMTP port. Alternatively, you can use this form if you have any valid email address password that exists on an external mail server, which accept SMTP connections.

The below are examples consists of 2 files, one that is the actual form your visitor will fill out and second one is the action file that authenticate and send the email.

    

STEP 1: CREATE THE FORM:

Copy the below code into your editor of choice and save it as contactform.htm

 

STEP 2: CREATE THE SEND FORM SCRIPT:

Copy the below code and save it as send_form.php (do not change the file name unless you changed it in the contactform.htm code above

 

STEP 3: UPLOAD THE FILES:

To test the files you created, FTP to your domain and create a test folder (i.e. smtp-form). Upload the both files to that directory. Once you have uploaded the files, browse to http://www.yourdomain.xyz/smtp-form/contactform.htm (or whatever you named the contact form from Step 1)

As long as if, you used an email address with valid server information, the email message should have arrived without error.