简体   繁体   中英

php email doesn't send from specified From: address

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\) <name@domain.tld>' . "\r\n" .
                'Reply-To: name@domain.tld' . "\r\n" .
                'Return-Path: name@domain.tld' . "\r\n" .

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


    mail($to, $subject, $body, $headers);

Try using quotes instead of escaping the parentheses:

$headers = 'From: "NAME (Info)" <name@domain.tld>' . "\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.

您是否尝试过将<name@domain.tld>放在发件人的标题中?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM