Jump to content

jimfog

Recommended Posts

In the PHP manual it is stated that the length of the lines of a message handled by the mail function should not exceed 70 characters.

 

Does that mean-in other words- that when setting a textarea for the message body of a contact form(for example) its cols attribute must not exceed 70?

 

Am I correct on the above?

Link to comment
Share on other sites

The cols attribute only limits the writing space, it doesn't actually force line breaks into the resulting string. The mail() part of the manual shows an example of how to break a string onto 70-character lines.

Link to comment
Share on other sites

No, the cols attribute controls how wide the text box is, you can still write lines longer and they will just wrap. It doesn't automatically add a line break to the text, it just shows the text on the next line.

Link to comment
Share on other sites

The mail() part of the manual shows an example of how to break a string onto 70-character lines.

I suppose you mean this.

 

$message = wordwrap($message, 70, "rn");

Edited by jimfog
Link to comment
Share on other sites

FWIW, mail is tricky. If you get beyond simple messages, you might want more help than the usual sources give you. Here's a trick I used. With a mail client like Thunderbird, I sent messages to myself. Thunderbird is good because it lets you view the raw source of your email -- the parts you see and the parts you don't see. Other programs do this too. Thunderbird is just an example.

 

One thing I learned is that the email client uses different header values depending on different circumstances. For example, if all your characters are plain ASCII, it sends one kind of Content-Type header. If you send some UTF characters, it sends another kind of Content-Type header. And if you send any HTML at all, or an attachment, or any combination of that, everything gets very complicated. This is why a lot of developers use Pear.

 

When you study the raw source for each kind of email, you can get a good idea how to format your own messages and headers. It's one thing to read the rules in the manual. It's another thing to read the specification. It's another thing to read tutorials. Seeing it done for real helped me understand it much better. (Tutorial authors almost always make an important mistake or forget to tell you something important.)

 

I also compared what I learned by studying the raw source generated by a different email client. Some things, there are multiple ways to get a thing done. Other things, you have to do it exactly the same way every time.

Link to comment
Share on other sites

I will see what options PEAR has to offer.

But I have 1 more question to make-a small one.

 

When I get a mail in Outlook I often see in the from field the mail the mail of the sender along with a name.

Example:

 

Test nesletter(test@nesletter).

 

Is it possible to adjust the header section of the mail function such that I can have the above result?

Or do I have to do it manually?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...