Jump to content

Recommended Posts

When recieving a php email and they put a 'from' email as: dfg@fgg.com, the email header shows as:

 

20120508.154346.png

 

 

Code:

 

<?php
if (isset($_REQUEST['email']))
{
$email = $_REQUEST['email'] ; //who is message being sent to?
$subject = $_REQUEST['subject'] ; //subject of email
$from = $_REQUEST['from'] ; //who will email be from?
$amount = $_REQUEST['amount'] ; //how many times do you want to send it?
$message = $_REQUEST['message'] ; //what will content of message be?
$from = $from;
$length = $amount;

for ($p = 0; $p < $length; $p++) {
mail("$email", "$subject", 
$message."\n-----------\nThank you for using the service", "From:" . $from);
}
}
$headers = "From:" . $from;
header('Location: success.php');

 

How would I make it show like: Website name etc.. <dfg@fgg.com>

Link to comment
https://forums.phpfreaks.com/topic/262255-from-header-not-displaying-properly/
Share on other sites

Allowing the user to specify an "amount" of times to send the email is insane an idea. You're also opening yourself up to the possibility of being black listed. I can't think of any constructive reason to allow that anyway?

 

To answer your original question, the "From" header can contain a name with an email in chevrons, just like your example:

 

$headers = "From: Website name etc.. <" . $from . ">";

Obviously you could insert the user's name or whatever in there instead of a static string. Although you should know that the "on behalf of" text is added in because, basically, the email is claiming to be from somewhere it's not. You won't be able to get rid of it dynamically inserting emails into the from address.

 

Edit The "Reply-To" header may be more what you're after?

Perhaps you had unknowingly white-listed the previous mail server or something? If you allow the user to provide the "From" header, then it's never going to match your mail server's domain (or your website's domain if they're different and you have a DKIM pass), and of course it wouldn't pass the SPF check. I'm no expert here though so someone else may say I'm wrong..?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.