0

I want to attach a pdf file that I created with TCPDF to my email.

This is how I do it:

$fileatt = $pdf->Output('file.pdf', 'E');

header("Location: mailto:someone@somepage.com?subject=my report&attachment=".$fileatt."&body=see attachment"); 

But I get an error message Warning: Header may not contain more than a single header


UPDATE:

Fred -ii- suggested to use Swiftmail to get this problem work:

$fileatt = $pdf->Output('quotation.pdf', 'E');

require_once 'swiftmailer/lib/swift_required.php';

// Create the mail transport configuration
$transport = Swift_MailTransport::newInstance();

// Create the message
$message = Swift_Message::newInstance();
$message->setTo(array(
  "someone@somewhere.com" => "Someone",
));
$message->setSubject("This email is sent using Swift Mailer");
$message->setBody("You're our best client ever.");
$message->setFrom("someone@somewhere.com", "Your bank");

// Send the email
$mailer = Swift_Mailer::newInstance($transport);
$mailer->send($message);

$message->attach(
Swift_Attachment::$fileatt);

But I still cannot figure out, how to combine this with the mailto

peace_love
  • 6,229
  • 11
  • 69
  • 157
  • use phpmailer for this. Once the header fired, there's nothing you can do for it after; this being attaching a file. Do it in the mailing function. – Funk Forty Niner Feb 17 '17 at 16:35
  • @Fred-ii- I do not know php mailer. It is not possible with "mailto"? – peace_love Feb 17 '17 at 16:36
  • Maybe; see this (external) thread http://forums.devshed.com/beginner-programming-16/using-mailto-attachment-66699.html or http://stackoverflow.com/q/5233556/1415724 and https://www.experts-exchange.com/questions/28738205/Attach-file-with-mailto.html and http://www.codingforums.com/html-and-css/9525-how-add-attachment-mailto.html for possible solutions or answers that may not work. – Funk Forty Niner Feb 17 '17 at 16:39
  • but I would suggest you use phpmailer/swiftmailer for this, it will be much easier and that way you won't have an email show to possible spammers – Funk Forty Niner Feb 17 '17 at 16:41
  • Ok, I will try swiftmailer. I hope this works with mailto – peace_love Feb 17 '17 at 16:45
  • @Fred-ii- I installed now swiftmailer, which works fine if I want to send an email. But I am wondering how I use it when I want to open my own client with mailto. I will edit my question to show you my result – peace_love Feb 17 '17 at 16:56
  • I don't understand what you mean, sorry. Those mailers attach a file and sends it to a pre-defined email. `mailto` has nothing to do with this and is a different animal altogether. – Funk Forty Niner Feb 17 '17 at 17:00
  • But my question was explicit to "mailto". Because I just want to open my own email client and attach the file there – peace_love Feb 17 '17 at 17:02
  • I do not want any automatic sending – peace_love Feb 17 '17 at 17:02
  • *"Because I just want to open my own email client and attach the file there"* - So use your own email client, choose the file to attach and send it to the recipient(s). If you're wanting to use this on a website, not everyone has an email client or may want to use it. I gave you links to consult. If none of those didn't work, then there isn't much else I can do here, sorry. Wait for someone else to visit the question; good luck. – Funk Forty Niner Feb 17 '17 at 17:09
  • You [can't attach files via mailto: links](http://stackoverflow.com/questions/2372036/attach-file-through-mailto-uri) at all. – Matvey Andreyev Feb 18 '17 at 08:12

0 Answers0