1

When I run this script to send an email, the email is being sent from serveradmin@myhosting. They say that the script isn't configured correctly.

I've changed the domain names and info shown below before posting here.

Is there really a problem with the scrip? The email sends, everything is fine. It takes a bit long...don't know why, the only problem is it doesn't send from the domain I specified.

    $to = $_POST['fes-email'];
    $subject = 'TEST';

    $body = 'TEST TEST';

    $headers =  'From: NAME \(Info\) <[email protected]>' . "\r\n" .
                'Reply-To: [email protected]' . "\r\n" .
                'Return-Path: [email protected]' . "\r\n" .

                'X-Priority: 1' . "\r\n" .
                'MIME-Version: 1.0' . "\r\n" .


    mail($to, $subject, $body, $headers);
2
  • 1
    Does it work if you remove the backslashes before the parentheses? I don't think it's needed.
    – Barmar
    Feb 12, 2015 at 1:51
  • It does. Just doesn't display whatever is written inside the parentheses. I am using the backslashes to escape the parentheses. Like you would use backslashes to escape double quotes inside double quotes, or single inside single.
    – Nikk
    Feb 12, 2015 at 1:52

2 Answers 2

0

Try using quotes instead of escaping the parentheses:

$headers = 'From: "NAME (Info)" <[email protected]>' . "\r\n" .

You should remove the Return-path: header. This header is always recreated by the receiving server, using the envelope information sent via SMTP.

9
  • The name appeared like is should without having to escape. However, when I looked at the headers Return-Path: <serveradmin@hostingdomain>, and also the envelope is signed by the same address. I am on media temple if that makes a difference, shouldn't.
    – Nikk
    Feb 12, 2015 at 1:59
  • Return-path is not settable by client applications. The receiving server creates that header by using the envelope sender address.
    – Barmar
    Feb 12, 2015 at 2:09
  • First time I'm playing with php email...going off what the hosting said. This is a link they suggested.
    – Nikk
    Feb 12, 2015 at 2:14
  • I think if you need to customize the envelope sender, that will have to be done in the PHP configuration. I'm not sure where.
    – Barmar
    Feb 12, 2015 at 2:23
  • Will something like this do anything mail('[email protected]','subject!','body!','From: [email protected]','-f [email protected]');? LINK
    – Nikk
    Feb 12, 2015 at 2:29
0

Have you tried putting just <[email protected]> in the headers for From?

1
  • I have...same thing. Just I'd like to also add a name. More appealing that way
    – Nikk
    Feb 12, 2015 at 2:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.