sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Sending Email With PHP - Special Characters Error

Collapse
This topic is closed.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending Email With PHP - Special Characters Error

    I have one of those things that should be simple, and yet for some reason it's throwing an error and no matter of trial and error seems to fix it.

    I have a php script on our iseries that is trying to send an email as the result of a form being submitted.

    The error I am getting is:

    PHP Warning: mail(): Unable to send message to SMTP server. Syntax error. Special characters only permitted with escape character.

    Zend Server Function Data shows the submitted values:

    PHP Error
    mail(): Unable to send message to SMTP server. Syntax error. Special characters only permitted with escape character.
    Function information
    mail (
    'fred@mydomain.com',
    'Contact Message from Web Site',
    'test',
    'MIME-Version: 1.0
    Content-type: text/plain; charset=iso-8859-1
    From: Tony <fred@mydomain.com>
    Reply-To: Tony <fred@mydomain.com>
    Subject: Contact Message from Web Site'
    )

    I can't see anything wrong with this, the "<" and ">" were coded correctly on output, and the only other special character is "@".
    The header lines were separated by \r\n.

    The line of code to send the email is:

    Code:
    $sent = mail($to, $subject, $email_body, implode("\r\n", $headers));
    Any ideas please? I have spent half a day trying everything I can think of.

    It's not a CCSID issue with the iSeries I assume? We are in the UK, but I can't think of anything that would cause this.

    ---------------------------------------------------------------------------

    Edited several hours later to add more information. Getting somewhere yet still getting nowhere...

    I hard coded the parameters for the PHP mail command as follows:

    Code:
    $sent = mail('tony@mydomain.com', 'test subject', 'test body', 'From: tony@mydomain.com');
    The error I get now is:

    mail(): Unable to send message to SMTP server. No recipients specified. ite. eady.
    Function information
    mail (
    'tony@mydomain.com',
    'test subject',
    'test body',
    'From: tony@mydomain.com'
    )

    The "ite. eady." is weird, doesn't appear in my sent data, and it's not even in the script I am using.

    Hoping this helps a light to come on somewhere...
    Poddys Rambles On

  • #2
    Re: Sending Email With PHP - Special Characters Error

    If all else fails..... check the PHP mail configuration on our old iSeries...

    SOLVED IT!

    PHP.ini was set up to use localhost (the iSeries) to send SMTP mail, the old machine was set up to let the mail server do the sending.
    A quick change to PHP.ini, Zend Server restart and it's working.
    Poddys Rambles On

    Comment


    • #3
      Re: Sending Email With PHP - Special Characters Error

      Nice work brother...
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment

      sponsored links

      Collapse

      Working...
      X