Sending emails with PHP

Discussion in 'General' started by Izinyoka, Mar 31, 2009.

  1. Izinyoka

    Izinyoka New Member

    When sending emails with PHP, (from looking at the logs) the from address is translated to 'webID'@servername.serverdomain.
    But when the email is delivered, the from address looks correct (mailbox@domain).

    So here is the example from my log:
    amavis[2564]: (02564-02) Passed CLEAN, <[email protected]> -> <sales@recipientdomain>, Message-ID: <[email protected]>

    So the server domain is not the same as the website sending the email.
    I can't even see a reference of the actual domain.

    some mail servers will not accept emails like this.

    said: 550-Verification failed for <[email protected]> 550-The mail server could not deliver mail to [email protected]domain

    But if it did a verification on the actual sender domain, it would be fine.

    When using Outlook, it does not do this. The address is correct, even when looking at the log.

    I had the same thing with ISPconfig2, just cant figure out what it is.
    Any help would be much appreciated.
     
  2. Izinyoka

    Izinyoka New Member

    -

    when looking at the Message source (on an email client once the message has been delivered), its only the 'return-path' that has the translated address, the actual 'from' is the correct email address.
    And the message ID is [email protected]domain
     
  3. Izinyoka

    Izinyoka New Member

    -

    yeah, it seems that the 'return-path' is taken from who delivers the email to postfix which is the user that apache ran the script as.
    Seems like there is much discussion about this but no real way to override it.
     
  4. edge

    edge Active Member Moderator

    Sure there is.
    Make sure you set a from email address in the header!

    PHP:
    $Name "Me"//senders name 
    $email "[email protected]"//senders e-mail adress 
    $recipient "[email protected]; //recipient 
    $mail_body = "Hello."; //mail body 
    $subject = "The subject of message"; //subject 
    $header = "From". $Name . " <" . $email . ">"; //optional headerfields 
    mail(
    $recipient$subject$mail_body$header);
     
    Last edited: Mar 31, 2009
  5. Izinyoka

    Izinyoka New Member

    There is a from address in the header and it is the correct one, but the return-path is the user apache is running as @ the server domain, not the actual hosted website's domain.
    And when the recipient mail server validates the email, it validates the return-path, not the from address.

    I understand this is how a normal Unix mail system would work. A user sends a mail, it uses the username @ domain, there is no seperate email field.

    I have been working on this issue on and off for almost 2 years... I doubt its going to be as simple as that.
     
  6. make-fun

    make-fun Member

    You may wanna try the so called "fifth parameter" or "5th parameter" of the mail function…
    PHP:
    $myParam "-f ".$email;
    mail($mailto$subject$message$headers$myParam))
    Cheers
     
  7. Izinyoka

    Izinyoka New Member

    Na...

    Na man, its not the script.
    It happens with Joomla, Indexu, Gallery2 etc.
    Im not gona go and edit the sendmail files on each application.

    The problem is with ISPConfig, not the PHP scripts...
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    The problem is in your script or setup and not ispconfig as ispconfig does not interfere in the mail sending process at all. The mail is handled by postfix and not ispconfig.
     
  9. Izinyoka

    Izinyoka New Member

    ...

    Yeah maybe not ISPConfig itself, but it NOT the script!!
    these are prebuilt scripts like Joomla, not something I made.

    E.G
    My hosted domain is test.com, my server is on lab.com
    The PHP script on the hosted domain sends an email using the PHP sendmail command, the user sending the email is [email protected] so it is understandable that this will be the return path.

    The from address is correct, [email protected], but when a mail server validates the sender, it validates the return path.
    So 95% of emails being sent from this server work fine, but the ones that validate the return path will not accept.

    This may be an unavoidable issue with hosting multiple domains, but maybe there is something that can be done? but if you don't know, don't tell me my script is wrong because it's not! you will just confuse people reading this.
     
    Last edited: Apr 9, 2009

Share This Page