+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
Coding Thread, email from to pdf file? in Coding and Web Development; what do you mean by sent in a html format>??...
  1. #16

    Join Date
    Apr 2010
    Posts
    13
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    what do you mean by sent in a html format>??

  2. #17

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,771
    Thank Post
    1,511
    Thanked 1,294 Times in 884 Posts
    Rep Power
    813
    Not being funny, but in the time spent dwelling on another way to do it (there's no simpler way to do it, not if you want it customised like you do) you could have had it up and running by now... take the plunge in to PHP, it's worth it (some might say essential) if you want a future creating websites

  3. #18

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    18,529
    Thank Post
    527
    Thanked 2,648 Times in 2,049 Posts
    Blog Entries
    24
    Rep Power
    925
    Quote Originally Posted by chrisboots View Post
    what do you mean by sent in a html format>??
    Email is sent in 2 formats - plaintext and html. When you have a form with action 'mailto:' you are effectively getting the end user to use their own email client and email server to send a plaintext email. What is being proposed is that the server you run the site on sends the email instead. It formats this email as an html email, so when it appears in the inbox of the recipient it is displayed as a formatted email (ie. however you design the html code to look).

  4. #19

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,771
    Thank Post
    1,511
    Thanked 1,294 Times in 884 Posts
    Rep Power
    813
    Quote Originally Posted by chrisboots View Post
    what do you mean by sent in a html format>??
    This is what we've been saying all along, you need to create a PHP script to create an HTML email on the fly in the format you want. If you can't do this and are unwilling to learn some basic PHP, you're going to have to pay somebody to do it for you I'm afraid. But honestly, PHP isn't that difficult, not at this level, just invest a couple of hours in it and you should be able to do what you're trying to, although if you don't really understand HTML, paying a professional might be the only way forward

  5. #20
    SteveBentley's Avatar
    Join Date
    Jun 2007
    Location
    Yorkshire
    Posts
    1,455
    Thank Post
    120
    Thanked 264 Times in 190 Posts
    Rep Power
    73
    If you're doing action="mailto:someone@example.com" then it's very likely to end in failure because it relies on the email client and web browser being properly set up. In these times when a lot of people don't actually have a proper mail client and just use webmail, it's no longer viable to use this method (if it ever was).

    You can (although probably shouldn't) do this in a single line of PHP, it's more trivial than it looks.

  6. #21

    CESIL's Avatar
    Join Date
    Nov 2006
    Location
    Hampshire
    Posts
    1,405
    Thank Post
    109
    Thanked 267 Times in 198 Posts
    Rep Power
    169
    I have built something like you need for a client.

    I used a library called DOMPDF and this allows me to produce a PDF file from an HTML page.

    In this case I am printing an order form which is built using PHP and CSS.

    This is called by DOMPDF and a PDF is created scaled to fit an a4 page.

    The hardest part is designing the page to get all the boxes etc where you want them.

  7. #22

    Join Date
    Sep 2009
    Posts
    47
    Thank Post
    6
    Thanked 11 Times in 10 Posts
    Rep Power
    12
    I've recently done this for a client, was used to send invoices to clients.

    I've simplified the code:

    Code:
    require_once '../_includes/swift/lib/swift_required.php';
    
    //SMTP details I used gmail because I couldn't get the email to be not counted as spam
    $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
      ->setUsername('youremail@gmail.com')
      ->setPassword('gmailpwhere')
      ;
    //Loads an the controller
    $mailer = Swift_Mailer::newInstance($transport);
    
    //Create the message
    $message = Swift_Message::newInstance();
    
    //Gives the message a subject
    $message->setSubject("Apperley Business Supplies Ltd -");
    
    //Set the From address with an array
    $message->setFrom(array('contact@yourwebsite.co.uk' => 'Email from'));
    
    //Set the To addresses with an associative array
    $message->setTo(array('contact@yourwebsite.co.uk' => 'Email to'));
    
    //Give it a body
    $body = "Hi,\n
    \n
    Website file Attached.\n
    \n
    Thanks,\n
    Named\n";
    $message->setBody($body);
    
    $htmlbody = "<html xmlns=\"http://www.w3.org/1999/xhtml\">
    <head>
    </head>
    
    <body>
    <p>Hi,</p>
    <p>Website file Attached.</p>
    <p>Regards,<br>
    Name
    </p>
    </body>
    </html>
    ";
      //And optionally an alternative body
    $message->addPart($htmlbody, 'text/html');
    
    
    //Creates a html file
    ob_start();
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style>
    body{
    	font-size:11px;
    	font-family:Verdana, Geneva, sans-serif;
    }
    </style>
    
    </head> 
    <body> 
    
    <? echo $_GET['texbox']; ?>
    
    </body>
    </html>
    
    <?php
    $invoicehtml = ob_get_contents();
    ob_end_clean();
    //End html files put it into a variable
    
    //Create the attachment with your data
    $attachment = Swift_Attachment::newInstance($invoicehtml, "file.html", 'text/html');  
    
    //Attach it to the message
    $message->attach($attachment);
    
    $result = $mailer->send($message);
    Last edited by rlweb; 22nd April 2010 at 06:10 PM. Reason: noticed a mistake with code

  8. #23
    SteveBentley's Avatar
    Join Date
    Jun 2007
    Location
    Yorkshire
    Posts
    1,455
    Thank Post
    120
    Thanked 264 Times in 190 Posts
    Rep Power
    73
    That looks interesting - have you got a link for the library you're including?

  9. #24

    Join Date
    Sep 2009
    Posts
    47
    Thank Post
    6
    Thanked 11 Times in 10 Posts
    Rep Power
    12
    Powerful component based mailing library for PHP – Swift Mailer

    Its a very easy to use class but I've found problems with smtp but that could my host.

  10. #25

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,867
    Thank Post
    412
    Thanked 778 Times in 651 Posts
    Rep Power
    182
    Quote Originally Posted by chrisboots View Post
    damn it!!. do you have any other suggestions on how to do it.
    Hire a programmer? Seriously, if your form is accessible to the public, it will be attacked sooner or later, and you need it written in a way that can deflect malicious submissions.

  11. #26
    Marci's Avatar
    Join Date
    Jun 2008
    Location
    Wakefield, West Yorkshire
    Posts
    897
    Thank Post
    84
    Thanked 235 Times in 194 Posts
    Rep Power
    83
    As pointed out, via PHP, submitting validated data into an SQL database is the proper way to go about the issue from a web perspective...

    but...

    If the original file that they want filling in is a PDF, open it in AdobeLiveDesigner (part of CreativeSuite)... make it into a web form... publish to web. You then end up with customers filling in a PDF form online which then gets emailed direct to whoever as an attachment, and looks exactly as you want it to.

    See Horbury :: ASLC :: Recruitment - click the "Application Form" link.

    Your employer will need to weigh up the cost of hiring a programmer to do it safely & properly via one method vs buying a copy of Adobe Creative Suite to continue as they're currently going about the job.
    Last edited by Marci; 29th April 2010 at 09:39 AM.



SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. OpenOffice3 to have PDF edit, Email, Calendar, etc...
    By mark in forum Educational Software
    Replies: 3
    Last Post: 28th January 2008, 08:40 PM
  2. changing email address in pdf doc's
    By dave-a in forum Windows
    Replies: 4
    Last Post: 14th May 2007, 11:10 AM
  3. PDF file edit
    By danIT in forum General Chat
    Replies: 2
    Last Post: 20th September 2006, 10:00 AM
  4. pdf file editting
    By russdev in forum Windows
    Replies: 7
    Last Post: 27th September 2005, 02:45 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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