APIs: Email client with single attachment

2329 views
Skip to first unread message

Scott Ferguson

unread,
May 7, 2013, 12:44:51 PM5/7/13
to

Note: as of 2013/05/07 I have been unable to get this project to send an email. I don't know what the problem is so I will no longer support it.

Thanks-

---sfs


*** If you implement this on your server you may want to have code in place to prevent the email client being used for sending spam emails. I had a problem with a developer sending multiple emails in less than 1 minute causing my internet hosting service to disable my server for a few days, so -- take necessary precautions! ***




I have just completed testing of a simple email client which uses a php server script to attach an uploaded file to the email. The test destination was my Gmail account. To simplify use and error handling, the fields for from, to, subject and message body must contain text, but the file attachment box is optional. Feel free to try it using my server as any uploaded files are deleted from a temporary directory on my server as soon as the email is forwarded to the mail server. I also am maintaining a log file containing time stamps, file names and file sizes. I have no way to identify any of your personal information, nor do I wish to. Also you may wish to improve on either the php script or the AI project (especially auto-entry of email addresses would be nice!). I will leave that to you. Have fun! By the way,  multiple file attachments are supported in the type of header used in this example, but that was beyond the scope of the project.

aimail.zip
aimail.php

Jeff Carter

unread,
Dec 21, 2012, 8:58:51 AM12/21/12
to app-inventor-de...@googlegroups.com
Scott
I have had success with sending the emails with attachment.  But everytime the file has 0kb.  No matter if it is a png, jpg or txt file.  All the files are on my cell phone, but can't get the file to actually email.   Any ideas?

Thanks

Jeff Carter

Scott Ferguson

unread,
Dec 23, 2012, 6:15:32 AM12/23/12
to app-inventor-de...@googlegroups.com
My first thought is to verify that the php script is using the correct location on the server for the attachment. Normally that would be a subdirectory of your working directory. I use 000webhost.com for my server and they have their own mail server. Other than that, I am pretty much clueless :(
---sfs

Lennart

unread,
Jan 24, 2013, 2:48:37 PM1/24/13
to app-inventor-de...@googlegroups.com
Thanx Scott, I will look into the php script and try to enable sending html mails

Matt Hutch

unread,
Jan 24, 2013, 3:08:25 PM1/24/13
to app-inventor-de...@googlegroups.com
Heya I was referred to this post from Taifun, I'm having trouble with my app, i can't seem to find a method of sending an email with a photo automatically attached. So when the user launches the camera and takes a photo that photo will automatically be attached when they launch the emailer. I'm not quite sure what i am doing here as i am rather new to developing, I have copied the comonents that you have used here and the blocks in block editor, is there any thing that i need to customize to get this to work for me? 

Scott Ferguson

unread,
Jan 24, 2013, 8:14:43 PM1/24/13
to app-inventor-de...@googlegroups.com
You would use the camera component to take a picture and the returned path to the picture would be attached to the email message. You could use the email client in this post to send the email, but you would have to set it up on your own php server. See www.000webhost.com for a free php server.
---sfs

Matt Hutch

unread,
Jan 25, 2013, 8:39:21 AM1/25/13
to app-inventor-de...@googlegroups.com
I think having a server is a bit too complex for me at the moment, so is this the only method of automatically attaching an image to an email client. Because the idea was for the user to fill out a form and at the end take a picture if needed, then they click a send button and it turns the form into text and launches the email client on the phone with all their inputted information, but need the photo to do the same when the click send (after they have confirmed the photo so i have the path). At the moment they have to manually attach the photo in the email client. Is this possible without the need of a server?

Lennart

unread,
Jan 25, 2013, 10:45:01 AM1/25/13
to app-inventor-de...@googlegroups.com
I looked into the php script, changing text/plain to text/html at line 58. would that enable the email body to be shown in html?

Scott Ferguson

unread,
Jan 26, 2013, 2:27:54 PM1/26/13
to app-inventor-de...@googlegroups.com
I don't know. I did not design the email script, just made a few modifications so you may try changing to text/html as a test case.
---sfs

Aaron Shuler

unread,
Apr 23, 2013, 12:54:30 PM4/23/13
to app-inventor-de...@googlegroups.com
I'm new to this. How do I know the return path of the picture I just took?

Taifun

unread,
Apr 23, 2013, 1:40:39 PM4/23/13
to app-inventor-de...@googlegroups.com
you will get it in the Camera.AfterPicture event, see an example here http://puravidaapps.com/snippets.php#picture
Taifun

Taifun

unread,
Feb 14, 2014, 6:03:13 PM2/14/14
to app-inventor-de...@googlegroups.com
I meanwhile prepared an App Inventor 2 example based on Scott's solution here http://puravidaapps.com/sendmail.php Thank you Scott!
Taifun

Shivendra Kr. Sahu

unread,
Jul 21, 2017, 6:49:24 AM7/21/17
to App Inventor Developers Library
how can generate apk file , when we use ur example 
?

Taifun

unread,
Jul 21, 2017, 9:33:45 AM7/21/17
to App Inventor Developers Library
you can't
use one of the solutions here instead http://puravidaapps.com/sendmail.php 
Taifun
Reply all
Reply to author
Forward
0 new messages