Jump to content

ingeva

Members
  • Posts

    31
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ingeva's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I prefer to use: function titlecase($name) { return mb_convert_case(trim($name),MB_CASE_TITLE); } In order to use it you MAY have to define the character set first: $charset = "utf-8"; mb_internal_encoding ($charset); I have similar functions for uppercase and lowercase. With the local functions you don't have to remember the MB_CASE_.... constants.
  2. When the username parameter is sent using the GET method (as it is here), you need to fetch it again using the GET method: $username = $_GET[name] .
  3. SOLVED! I found the iconv_mime_decode function.
  4. I've written a mailing/discussion-list script which saves (archives) messages sent through the list. I'm now working on a script to enable the members to read archived e-mails. My problem is with character conversion. For each e-mail message, the date and subject are displayed. Members send their messages with different coding, and when the subject contains national characters, it can look like this: [alle] =?Windows-1252?Q?FW:_Morgen?= =?Windows-1252?Q?dagens_=F8ve?= or [alle] =?UTF-8?B?QW5nw6VlbmRlIGlubmxvZ2dpbmc=?= which is not very nice. I've searched for a function that can do the correct conversion (to UTF-, but no luck. When the e-mail files are displayed with Thunderbird or even Outlook Express (!!) the subject comes out just fine, so there IS definitely a way to do this! Appreciate all help.
  5. GOT IT! The simplest is always the best. PHPmailer gone. The clue was that I had let the leading hyphens be a part of the mime boundary, instead of Inserting them before it. I now get the body text in utf-8 and the attachment in the message (attachment inline) and also readily available to save or open separately. I have removed an element of uncertainty, and I have learnt a lot. Thank you for all your help! Without it I might have given up, but I'm not an easy quitter. PHPmailer and SwiftMail still look interesting enough, so I'll probably look into them again when it becomes relevant, for instance if I need smtp send.
  6. This error appeared because I had reversed the error test. The mail was actually sent, but without the body text. I changed my script thus: <?php // ************** Sends the member list. ************* include_once "class.phpmailer.php"; $CharSet = "utf-8"; $mail = new PHPMailer(); // defaults to using php "mail()" $mail->AddAddress($email1, $name); $mail->From = "$MyMail@$domain"; $mail->FromName = "Inge Vabekk"; $mail->Subject = "Sending email with attachment"; $mail->Body = "Testing mail with attachment\n"; $string = "Navn,Sted,Hjemme,Jobb,Mobil,Stemme Inge Vabekk,1338 Sandvika, 456456456,99,123 Anne Lise,1341 SLEPENDEN,6756 6609,2203 3239,9504 6588, Anne Swang,3440 Røyken,,,, 3 medlemmer totalt. "; $mail->AddStringAttachment($string, "mlist.csv"); // , $charset, "text/csv"); if($mail->Send()) echo "Mail sent to <$email1>.<br />\n"; else echo "Could not send mail!<br />\n"; ?> Note the $CharSet above. Although I set the variable name to what was defined in the class as "public $CharSet", the body text still came out with the iso-8859-1 character set. This is not good since MS software doesn't interpret it correctly. We could live with it for this one mail since it would hardly contain "strange" characters, but if you know how to change it I would be happy, and we could use phpmailer for other purposes as well (although I still think it's an unnecessarily complicated solution)! If I can find out how, I'll mark this as solved.
  7. Tried that. Result: Could not send mail! Any more suggestions? This should really be quite simple, and adding a complicated library like this doesn't seem to be the right thing to do. I don't understand how it works, and I hate the idea of having to debug unknown code (and php's debugging is lousy!!!) in order to find a minor error like this. Because it IS a minor error, since only a minor change changes a working e-mail to a non-working. However, even if I change a previously working mail back to the original, it won't work!!!! It looks as if someone or something is out to get me. It's a long time since I've had this kind of trouble for such a minor thing. Before I scrap it altogether I'll try phpmailer support. Thanks for trying!
  8. Evidently I could do that but it should be unnecessary. In fact, all attachments are "inline" since they are only separated from each other and the body by a mime boundary. Anyway, I found the AddStringAttachment function which ought to do the trick. However, after a day's work I'm not even where I started. This is going from bad to worse. No error messages, but no mail, not even one that my mail clients made invisible (I use Thunderbird, but Outlook Express acts the same way). Here's my code with phpmailer. Can someone see an obvious error? <?php // ************** Sends the member list. ************* include_once "class.phpmailer.php"; $charset = "utf-8"; $mail = new PHPMailer(); // defaults to using php "mail()" $body = "Testing mail with attachment\n"; $mail->AddAddress($email1, $name); $mail->From = "$MyMail@$domain"; $mail->FromName = "Inge Vabekk"; $mail->Subject = "Sending email with attachment"; $string = "Navn,Sted,Hjemme,Jobb,Mobil,Stemme Inge Vabekk,1338 Sandvika, 456456456,99,123 Anne Lise,1341 SLEPENDEN,6756 6609,2203 3239,9504 6588, Anne Swang,3440 Røyken,,,, 3 medlemmer totalt. "; $mail->AddStringAttachment($string, "mlist.csv", $encoding ="$charset", $type = "text/csv"); if(!$mail->Send()) echo "Mail sent to <$email1>.<br />\n"; else echo "Could not send mail!<br />\n"; ?>
  9. OK, thanks, I'll have to look into that. My attachment is not on file, however. It's just a long string. Should be able to use an inline attachment.
  10. OK, I'll look into that also. I would need months to find out how to use the swiftmailer, so I feel that we're trying to fix a small problem using a very big gun. I don't know how to use classes; have never used them, and I really don't have much time to learn about them. I need a solution, the faster the better. I don't understand how installing another package would make things simpler. Adding more software is adding another level of complexity. How can I do it as simple as what I have already done -- or simpler? I don't need a volume mailer, or anything sophisticated. It will be used more or less sporadically, like once or twice a week, max. about 40 mails each time. My mails are OK as long as they don't have an attachment. Then they appear blank to the receiver, even if they are not. It only shows if the mail is saved and viewed in text mode. There's evidently just a format error, like in the header or in the mime boundary.
  11. Thanks, I'll probably look into that anyway, but since I've tried to copy the exact method from examples I have found, I thought there would be only a minor error; something I had overlooked. I hoped I would have a solution by today, and I believe it would take me more time to study and install this new library, than to find and eliminate the error. It would be a great advantage if I could install the library on my own computer also, so I had a better way of testing my mail scripts. I run Ubuntu Linux. Tips?
  12. I have read all I could find about sending email attachments, but it seems that whatever I do the received email is blank. If I save it to a file all the information is still there. I want to send a simple e-mail with a .csv attachment. This is also pure text, no special encoding. If I send an "identical" mail from my mail client, everything is fine. If I make a slight adjustment in this file, for instance I change only one character in the mime boundary (all of them), the same thing happens, so I suspect that there is something about making the boundary that I have not understood (and no example explains it). Here's the php script that I now use for testing. Only the "$to" values need to be set for testing. Can anyone see what's wrong here, and inform me what I have to change? Thanks! Here's the code: <?php // ************** Sends the member list. ************* $to = "$name <$email1>"; $charset = "utf-8"; $subject = "Sending email with attachment"; $boundary = "----".md5(time().time()); $Lhead = <<<nn From: Inge Vabekk <inge@secretdomain.com> MIME-Version: 1.0 Subject: Testing Content-Type: multipart/mixed; boundary="$boundary" nn; $body = <<<mm This is a multi-part message in MIME format. $boundary Content-Type: text/plain; charset="$charset"; format=flowed Content-Transfer-Encoding: 8bit Testing mail with attachment $boundary Content-Type: text/csv; name="mlist.csv" Content-Transfer-Encoding: 8bit Content-Disposition: inline; filename="mlist.csv" Navn,Sted,Hjemme,Jobb,Mobil,Stemme Inge Vabekk,1338 Sandvika, 456456456,99,123 Anne Lise,1341 SLEPENDEN,6756 6609,2203 3239,9504 6588, Anne Swang,3440 Røyken,,,, 3 medlemmer totalt. $boundary-- mm; if (mail ($to, $subject, $body, $Lhead)) echo "Mail sent to <$email1>.<br />\n"; else echo "Could not send mail!<br />\n"; ?>
  13. Check the weekday of the first of the month.
  14. A CSV file is a text file, and you can read it with any editor. To make a text editor the default handler for the file, just rename it and give it a .txt extension. If you want to keep the original, copy the file, giving the new file at .txt extension. Example: $file = file_get_contents ("csv-filename.csv"); file_put_contents ("txt-filename.txt",$file); It shouldn't be much more complicated than that.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.