SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to Post to Blog via Email?

    Would like to email an address and have its contents posted in a blog, similar to what sites like Flickr and Blogger allow you to do. Anyone know what I need to make this happen? An email parser/handler? Email gateway? Is there any way to forward an email to a webpage for processing?

  2. #2
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't forward an email to a web page, but you can have your web page check an email account, and act on the contents. This would require that you either use someone elses plugins or code to do this, or write your own.

  3. #3
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this has intrigued me! so i'm guessing the process would be something like:

    1. setup a pop3 email account specific for this use.
    2. create a page that checks this account for messages.
    3. add these messages to a database.

    this would take a fair bit of looking into the cfpop tag but it definately sounds do-able.

    http://www.cfquickdocs.com/?getDoc=cfpop

  4. #4
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CFPOP would be the way to go

  5. #5
    SitePoint Wizard mcsolas's Avatar
    Join Date
    Jul 2004
    Location
    Hermosa Costa Rica
    Posts
    1,710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When your done, can you post us the email address so we can .. ..see how it works?

    All Im saying is that you would want some form of checking post validity, in case this email ever gets 'known'. You would be a sitting duck for comment spammers.

  6. #6
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah - it would be a little risky, having a totally random username in the email address would help to deter spammers. you could also do some checking before the script posts for the usual list of spam words, etc.

  7. #7
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hopefully this would be a completely random, long, email address that you'd only know because it was in your address book. And you would never post it on any site.... anywhere. Never. Ever.

  8. #8
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought that this was a really fun concept so I decided to write a quick and dirty "post via email" snippet. You can see the result here:http://www.andyandjaime.com

    Here's the email that I sent:
    [start]
    General:Andy
    ~~~~~
    That's right...

    Usually Jaime and I add posts to our site via an elaborate admin section that I built. But this post was added via my new "email post" method. It's more of a proof-of-concept than something that will get used often, but heck. I'm a guy, I'm a programmer, and I like building new things. So I took the time to write this extra setup just because.
    [/end]

    The first part (above the ~~~~~) are the category names. The second part is the contents of the email. It would get inserted into the database as plain code, with no trimming or anything. So you could use any HTML or javascript that you choose.


    And here's the code itself. I'll set this up as a Coldfusion scheduled task, running every 15 minutes or so. That should be plenty sufficient.
    PHP Code:
    <!--- get all emails --->
    <
    cfpop server="your mail server" username="the email address to check" password="password" action="getAll" name="emails">

    <!--- 
    loop over the emails to see if there are any legit records in there --->
    <
    cfloop query="emails">

        <!--- 
    make sure that the current email being evaluated matches our "special" email --->
        <
    cfif FindNoCase("special email two",to) OR FindNoCase("special email one",to)>

            <!--- 
    prep the variables for insertion to the database --->
            <
    cfif FindNoCase("special email two",to)>
                <
    cfset fk_user_id 1>
            <
    cfelseif FindNoCase("special email one",to)>
                <
    cfset fk_user_id 12>
            </
    cfif>
            <
    cfset thedate DateFormat(Now(),"yyyy-mm-dd") & " " TimeFormat(Now(),"H:mm:ss")>
            <
    cfset title subject>
            <
    cfset content ListLast(body,"~~~~~")>
            <
    cfset cats ListFirst(body,"~~~~~")>
            <
    cfset status "publish">

            <!--- 
    insert into database --->
            
    perform your db insert here

            
    <!--- get newest news post --->
            
    get the id of the just inserted record

            
    <!--- loop over the categories to get the corresponding id --->
            <
    cfset counter 0>
            <
    cfloop index="li" list="#cats#" delimiters=":">
                
    look upthe current category and make sure that one exists with that name

                
    <!--- did we get a hit? --->
                <
    cfif getCat.recordcount>
                    <!--- 
    we did get a hitso insert a record--->
                    
    insert the user/newsid record here8

                    
    <!--- keep a count to make sure that at least ONE category got added --->
                    <
    cfset counter counter 1>
                </
    cfif>
            </
    cfloop>

            <!--- if 
    counter is still zerothen delete the news post --->
            <
    cfif NOT counter>
                
    delete the news post
            
    </cfif>

        </
    cfif>
    </
    cfloop>

    <!--- 
    everything went wellso delete all emails --->
    <
    cfpop server="your mail server" username="the email address to check" password="password" action="getAll" name="delete"
    Last edited by creole; Nov 1, 2006 at 09:31.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  9. #9
    Take The Blue Pill neilmerton's Avatar
    Join Date
    Jul 2004
    Location
    Leicester, UK
    Posts
    871
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    superb stuff Andy!

  10. #10
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So Andy, what's the email address used ?

  11. #11
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  12. #12
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, sent an email, how long before it's on your blog :-P

  13. #13
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any minute now. Just keep refreshing. While you're at it, click on a few of my banners.

    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  14. #14
    SitePoint Guru
    Join Date
    Jul 2005
    Posts
    609
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HEY! It Bounced back!!!

  15. #15
    SitePoint Addict gl3nnx's Avatar
    Join Date
    May 2005
    Location
    at http://www.gl3nnx.net
    Posts
    344
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know posting a blog post using email is possible from wordpress, but not with blogger.
    Last edited by gl3nnx; Nov 2, 2006 at 19:50.

  16. #16
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sending a blog post via mail is possible in Blogger. Here's the instruction: http://help.blogger.com/bin/answer.p...452&topic=8929


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •