php mail- headers 
June 12th, 2009, 05:21 AM
| | Member | | Join Date: Mar 2008 Location: India
Posts: 100
| |
hi
i m sending mail using php mail().
while adding headers i m adding the email id in the header dynamically., -
<?
-
//static value is passed
-
$header ="From: ".$fname." <example@example.com>\r\n";
-
-
-
//output when header is printed i get
-
From: vijay <example@example.com>
-
-
-
//but when dynamically passed
-
$header ="From: ".$fname." <".$agentmailid.">\r\n";
-
-
//output when header is printed i get
-
From: vijay
-
-
-
-
?>
-
why does the mail id not getting displayed when passed through an variable..
regards
vijay
| 
June 12th, 2009, 08:07 AM
|  | Familiar Sight | | Join Date: May 2009 Location: Wellington, New Zealand
Posts: 152
| | | re: php mail- headers
hey
1. you might have have a problem with "$agentmailid" variable. coz your header is giving me From: Name[example_from id]
2. could try with the code below -
-
those are the example of normal php mail() function variables..
-
$to = "example_to@xxx.co.nz";
-
$subject = "Test mail";
-
$message = "Hello ! This is a simple email message frm Vijay.";
-
$from_mail = "example_from@xxx.co.nz";
-
-
//or could use
-
$from_mail = $agentmailid;
-
$from = $fname."<$from_mail>\r\n";
-
$header = "From: $from";
-
mail($to,$subject,$message,$header);
-
-
:)
| 
June 12th, 2009, 10:28 AM
|  | Moderator | | Join Date: Nov 2006 Location: Iceland
Posts: 3,701
Provided Answers: 4 | | | re: php mail- headers
As usually, I recommend using PHPMailer to send emails.
It takes care of all this kind of stuff for you.
| 
June 12th, 2009, 10:52 AM
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,862
Provided Answers: 9 | | | re: php mail- headers Quote:
Originally Posted by Atli As usually, I recommend using PHPMailer to send emails.
It takes care of all this kind of stuff for you. | SwiftMailer! SwiftMailer! SwiftMailer! | 
June 12th, 2009, 11:29 AM
|  | Moderator | | Join Date: Nov 2006 Location: Iceland
Posts: 3,701
Provided Answers: 4 | | | re: php mail- headers Quote:
Originally Posted by Markus | Or that. Same thing, different packaging :P
I do like the way SwitfMailer returns $this, allowing you to stack method calls.
Not sure PHPMailer does that to.
| 
June 12th, 2009, 11:37 AM
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,862
Provided Answers: 9 | | | re: php mail- headers Quote:
Originally Posted by Atli Or that. Same thing, different packaging :P
I do like the way SwitfMailer returns $this, allowing you to stack method calls.
Not sure PHPMailer does that to. | Gotta love method chaining :D
SwiftMailer seems much more professional, tbh. Pretty complex too; very well written.
| 
June 12th, 2009, 12:07 PM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,487
Provided Answers: 9 | | | re: php mail- headers Quote:
Originally Posted by Markus SwiftMailer seems much more professional, tbh. Pretty complex too; very well written. | gotta agree with that, my favourite is sending customizable batch mails.
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|