How to make sendgrid work on digitalocean?

March 17, 2015 2.8k views
Messaging DigitalOcean

I'm trying to use sendgrid to send mail. But I'm unable to make it work on digital ocean. It's working on localserver, it's even working on another host I uploaded. But in digital ocean, it seems to stop running the script after it receives curl request. Any suggestion how can I solve that?

  • Hey! It's hard to give you a good answer without some more information. How are you using Sendgrid, via the API or their SMTP relay? Could you provide a code snippet?

  • @asb I'm using SMTP relay. It is a form where users will enter email address and some other information and after submission, a mail will be sent to that email address with some attachments. This is a working version of that application - http://www.aan-nahl.com/test/tanvir/ibeacon-tool/
    Do I need to install curl seperately or does it come with php bundle?

  • The PHP cURL module is not installed by default. On an Ubuntu system, you can install it with sudo apt-get install php5-curl

  • Is it possible to get a list of steps, from start to finish? Here is my attempt:

    Option #1
    Insert the following html form into the index.html file
    Create another page, emails.html to display the incoming messages.
    The Parse API posts the parsed email to the url of this new page.

    To set up the Parse API to forward incoming email to this new webpage:
    (SendGrid's Parse API lets your app accept incoming email and perform some operation on the content.)

    Create a Digital Ocean account and droplet
    Log in to your server domain
    Go to the DNS settings
    Create a new record - MX
    Set the TO section to mx.sendgrid.net

    Create a SendGrid account
    Go to the Parse Settings page on https://app.sendgrid.com/settings/parse
    Click the green "Add Host & URL" button
    Under hostname, enter mydomain.com
    Under URL enter the URL http://mydomain.com/emails
    Select "Spam Check" if desired
    Select "Send Raw" to receive a raw message

    *Option #2:
    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:
    FEATURE(authinfo',hash /etc/mail/auth/client-info')dnl

    sudo sendmailconfig

    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):


    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

1 Answer

This question was answered by @asb:

The PHP cURL module is not installed by default. On an Ubuntu system, you can install it with sudo apt-get install php5-curl

View the original comment

Have another answer? Share your knowledge.