I have an html contact form on my website. How can visitors email me from my contact form?

December 28, 2015 1.8k views
Email Getting Started Ubuntu

This code from W3C schools for an html form does not address the backend server side code needed to actually send an email.

Please tell me the fastest, easiest (non php) way of triggering an email to my info@domain.com address.

Cheers,

<!DOCTYPE html>
<html>
<body>

<h2>Send e-mail to someone@example.com:</h2>

<form action="MAILTO:someone@example.com" method="post" enctype="text/plain">
Name:<br>
<input type="text" name="name" value="your name"><br>
E-mail:<br>
<input type="text" name="mail" value="your email"><br>
Comment:<br>
<input type="text" name="comment" value="your comment" size="50"><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>

</body>
</html>

3 comments
  • When you typed in sudo sendmailconfig, you should have been prompted to configure sendmail.

    For reference, the files that are updated during configuration are located at the following (in case you want to update them manually):

    /etc/mail/sendmail.conf
    /etc/cron.d/sendmail
    /etc/mail/sendmail.mc

    You can test sendmail to see if it is properly configured and setup by typing the following into the command line:

    $ echo "My test email being sent from sendmail" | /usr/sbin/sendmail myemail@domain.com

  • What about Sendmail and Sendgrid? I found this answer on StackOverflow:

    Change to your mail config directory:
    cd /etc/mail

    Make a auth subdirectory
    mkdir auth
    chmod 700 auth #maybe not, because I cannot apply cmd "cd auth" if I do so.

    Create a file with your auth information to the smtp server
    cd auth
    touch client-info

    In the file, put the following, matching up to your smtp server:
    AuthInfo:your.isp.net "U:root" "I:user" "P:password"

    Generate the Authentication database, make both files readable only by root
    makemap hash client-info < client-info
    chmod 600 client-info
    cd ..

    Add the following lines to sendmail.mc. Make sure you update your smtp server The first single quote for each string should be changed to a backtick (`) like this:
    define(SMARTHOST',your.isp.net')dnl
    define(confAUTH
    MECHANISMS',EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    FEATURE(authinfo',hash /etc/mail/auth/client-info')dnl

    run
    sudo sendmailconfig

  • The latest response from SendGrid:

    *Hi there,

    The easiest way to send emails through your form is with the web API call.

    When somebody fills in the form, and clicks on send, you will get the data from the form, add is as content to the email, and then send it to your email address. Of course all this needs to be done programmatically.

    In case you need further assistance regarding this matter, please feel free to contact the SendGrid Support Team at any time.
    We all wish you a great day!

    Best regards,
    Victor A*

Be the first one to answer this question.