Click here to Skip to main content
15,666,844 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi there

I am trying to send an online form to pdf attachment via smtp settings and not client software.

Is there script that I can use to do this, either java script I can call,

Please help

I have adobe pro if that will help, or guidance please

What I have tried:

Been looking around for answers and saw this on your page
function sendMail()
var link = ""+
"&subject=" + escape("This is subject")+
"&body=" + escape("This is body");
window.location.href = link;

I know this will not do what I want, but please help me.
Updated 18-May-16 5:04am
Sergey Alexandrovich Kryukov 17-May-16 13:06pm    
I don't know what is "via smtp settings and not client software". You are trying to do it on the client side, why? What do you have on server side, if any?
If you want to allow the client to use client software, all you need is the anchor with e-mail address, but not all clients will be able to use it directly.
Member 12529008 17-May-16 13:21pm    
HI there, sorry was not clear enough, I want to take an online form, create an button, when you press the button I want to send an email to a certain email address with the total online form attached. now this is where the trick is, I need to pre configure the script to send the email directly from the online form, php or html page. that I can configure. I don't want to uses the clients software, outlook, webmail, gmail. the mailto: works but sends only the inserted data. I want the complete form to be sent.

Please look at example I need to send this form to an email address as attachment. with preconfigured smtp settings to send out the mail

Thank you in advance
Sergey Alexandrovich Kryukov 17-May-16 13:27pm    
"Online form" is something handled on the server side, because a form sends HTTP request. Without it a form is pointless. JavaScript does not send mail, it can use some server or client-side mail program, which may or may not be installed.
In the code sample you reference, there is a form:

<form name="page1Form1" method="post" action="page2.php" enctype="multipart/form-data" id="page1Form1">
<!-- ... -->

Pay attention: it sends HTTP request to "page2.php". You also should have some server-side script.

Member 12529008 17-May-16 14:19pm    
Thank you for the reply, is there any other way of doing this? accept the site like jotform. None of them is custom forms!
Sergey Alexandrovich Kryukov 17-May-16 14:41pm    
Another way is Ajax, but why?
Look, you need to tell us what do you have on the server side, otherwise there is no thing to talk about.
There is no such thing as "custom form" or "non-custom". Form is a form.

1 solution

Here is the bottom line:

From the discussion in comments, it seems that you are not using server-side scripting at all. No, without server-side scripting, you cannot do anything at all. JavaScript does not send mail, it can only send HTTP request to the server side where you serve up such request by sending mail or anything else. If you use HTTP form, you don't even need JavaScript.

"Using mailto" simply means URI scheme, the one which could be used in a regular anchor. If you use such anchor on your page, it will simply load the default mail application and pass some command-line parameters to it. It also cannot help you. Moreover, you cannot even assume that a user has any mail application at all. This technique is nothing but providing contact information and saying "please send e-mail by yourself", only with some minimal convenience.

So, you always need some server-side scripting to compose and send mail. In principle, you can use some external service provided for this purpose. What I were always services operating by paid subscription. It's hard to imagine that it would make any sense for the developers having their own Web sites.

From your reply about having cPanel and 1 SQL database, I can conclude that you probably use more or less standard Web hosting, maybe LAMP. All standard hosting plans, as a bare minimum, support PHP. This is not the best language and server-side technology, but it provides some minimal tool for sending mails with attachments.

Here is how you deal with forms with PHP: PHP: Dealing with Forms — Manual[^].

Two major options for sending mail:[^],
Manual :: sends a mail[^] (requires PEAR:
   Manual :: About PEAR and PEAR2[^]).

The major problem with handling forms in general and with sending mail is security. You have to sanitize everything on the server side when you handle an HTTP Web request. For one very basic exploit, please see my past answer: unable to send mail , it showing the error in below code .[^].

You need to add mail parts representing PDF "attachment". This is just a part of your mail text with separate content-type and content-disposition headers. Please see:
Media Types[^] (note: "application/pdf"),
MIME — Wikipedia, the free encyclopedia[^].

You have to learn all this stuff to be able to compose mail messages and send them. You also need a properly set up SMPT server (or something else), which is usually provided with your mail hosting.

I don't mean to recommend PHP here, I write about it because I cannot assume too much about your hosting environment. It's possible that you can use something better. You may need to call your hosting customer service for an advice.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900