NYCPHP Meetup

NYPHP.org

[nycphp-talk] Email Pain

Michael B Allen ioplex at gmail.com
Sat Aug 9 23:33:53 EDT 2008


On Sat, Aug 9, 2008 at 10:38 PM, (Margaret) Michele Waldman
<mmwaldman at optonline.net> wrote:
> Folks,
>
>
>
> I'm working with this mail function again.
>
>
>
> Unhappily.
>
>
>
> The mail message is created using data off of an html form using radio
> buttons, selects, text input, etc.
>
>
>
> The oddest thing is happening.  Sometimes newlines are ignored.
>
>
>
> Where formated like this:
>
>
>
> $message = @<<<END
>
> This is field 1: $field1
>
> This is field 2: $field2
>
> This is field 3: $field3
>
> This is field 4: $field4
>
> END;
>
>
>
> Or like this:
>
> $message = "This is field 1:".$field1."\n";
>
> $message .= "This is field 2:".$field2."\n";
>
> $message .= "This is field 3:".$field3."\n";
>
> $message .= "This is field 4:".$field4."\n";
>
>
>
> The message might look like this:
>
>
>
> This is field 1: data
>
> This is field 2: data This is field 3: data
>
> This is field 4: $field4

What mail sending routines are you using?

If you're using the 'mail' function, first simplify your test case.
Try something like the following:

  $email = 'whomever at example.com';
  $subject = 'This is the subject';
  $headers = "From: $email\r\nReply-To: $email";
  $message = "This is a message\nwith multiple\nlines\nof\ntext\n";
  mail($email, $subject, $message, $headers);

Note that the headers should use "\r\n" as opposed to just "\n"
(technically you should use the linebreak indicated by the server but
that's more involved).

If that works, then narrow down the difference with trial and error.

If it doesn't work, get a packet capture, open it with WireShark and
verify the content of the outgoing message. If the message is screwed
up going out that narrows down things quite a bit.

Mike

-- 
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/



More information about the talk mailing list