View previous topic :: View next topic |
Author |
Message |
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Thu Jun 15, 2006 9:16 pm Post subject: Sending emails with my real name |
|
|
I've been playing around with mail() for a little while now. I'm using this row to send an email to whoever requests a new password:
mail($sqlitedata['email'], "Forgotten password", "Your new password: " . $newpw, "from: password@2q4u.com");
That script works. Still, I would like it if I could write "Password recovery" as the sender, so it will show up in the list instead of the email-address.
I've tried replacing password@2q4u.com with "Password recovery" <password@2q4u.com>, but that didn't work. PHP just keeps returning false on mail().
Does anybody have any idea of what I should put in the email header?
Last edited by cmxflash on Fri Jun 16, 2006 11:20 pm; edited 1 time in total |
|
Back to top |
|
|
lspence -
Joined: 16 Jul 2004 Posts: 15
|
|
Back to top |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Thu Jun 15, 2006 10:18 pm Post subject: Re: Sending emails with my real name |
|
|
cmxflash wrote: | I've been playing around with mail() for a little while now. I'm using this row to send an email to whoever requests a new password:
mail($sqlitedata['email'], "Forgotten password", "Your new password: " . $newpw, "from: password@2q4u.com");
That script works. Still, I would like it if I could write "Passwprd recovery" as the sender, so it will show up in the list instead of the email-address.
I've tried replacing password@2q4u.com with "Password recovery" <password@2q4u.com>, but that didn't work. PHP just keeps returning false on mail().
Does anybody have any idea of what I should put in the email header? |
Have you tried adding a new line (\n or \r\n) to the end of the from header?
I also found this on php.net
Quote: | Note: The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine).
Second, the custom headers like From:, Cc:, Bcc: and Date: are not interpreted by the MTA in the first place, but are parsed by PHP.
As such, the to parameter should not be an address in the form of "Something <someone@example.com>". The mail command may not parse this properly while talking with the MTA. |
source: http://uk.php.net/manual/en/function.mail.php
I am guessing that this applies to the other headers _________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
|
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Thu Jun 15, 2006 10:34 pm Post subject: Re: Sending emails with my real name |
|
|
roganty wrote: | Have you tried adding a new line (\n or \r\n) to the end of the from header? |
Yes, I've tried that. In fact, I've tried every single example I could find in the documentation. Nothing seems to work. |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Fri Jun 16, 2006 12:06 am Post subject: |
|
|
I /know/ using "From: Symphonics <symphonics@inter.net>\r\n" works. _________________
|
|
Back to top |
|
|
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Fri Jun 16, 2006 12:38 am Post subject: |
|
|
MonkeyNation wrote: | I /know/ using "From: Symphonics <symphonics@inter.net>\r\n" works. |
Dosn't work.
Here's the code I tried:
Code: | <?php
mail("nospam@elev.it-gymnasiet.se", "Some boring subject", "Aprelium rocks", "From: Cmxflash <cmx@microsoft.com>\r\n");
?> |
However, this one works for some reason:
Code: | <?php
mail("nospam@elev.it-gymnasiet.se", "Some boring subject", "Aprelium rocks", "From: <cmx@microsoft.com>\r\n");
?> |
|
|
Back to top |
|
|
cyberstyles -
Joined: 04 Jun 2006 Posts: 31
|
Posted: Fri Jun 16, 2006 9:12 am Post subject: |
|
|
it would sound like you need to write a whole new command line just replacing a command with a new command when its not a normal part of that line dont seem it works that way so it does seem you need to write a new command there not just replace a command. |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Fri Jun 16, 2006 10:45 am Post subject: |
|
|
cmxflash,
Here is a part of the code we use to send emails to our customers:
Code: | function send_message($from, $to, $subject, $message)
{
return (mail($to, $subject, $message,
"From: \"Aprelium Technologies\" <$from>\n"
. "Reply-To: \"Aprelium Technologies\" <$from>\n"
. "Return-Path: \"Aprelium Technologies\" <$from>\n"
. "MIME-Version: 1.0\n"
. "Organization: Aprelium Technologies\n"
. "X-Priority: 3\n"
. "Content-Type: text/plain; charset=UTF-8; format=flowed\n"
. "Content-Transfer-Encoding: 8bit\n","-f$from")==1);
} |
_________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Fri Jun 16, 2006 11:08 am Post subject: |
|
|
aprelium wrote: | cmxflash,
Here is a part of the code we use to send emails to our customers:
Code: | function send_message($from, $to, $subject, $message)
{
return (mail($to, $subject, $message,
"From: \"Aprelium Technologies\" <$from>\n"
. "Reply-To: \"Aprelium Technologies\" <$from>\n"
. "Return-Path: \"Aprelium Technologies\" <$from>\n"
. "MIME-Version: 1.0\n"
. "Organization: Aprelium Technologies\n"
. "X-Priority: 3\n"
. "Content-Type: text/plain; charset=UTF-8; format=flowed\n"
. "Content-Transfer-Encoding: 8bit\n","-f$from")==1);
} |
|
Tried that out, doesn't seems to work on Windows. However, it works on a *nix machine I have access to.
Last edited by cmxflash on Fri Nov 10, 2006 9:20 pm; edited 1 time in total |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Fri Jun 16, 2006 12:16 pm Post subject: |
|
|
Which operating system are you using and which SMTPd?
Check the SMTPd's logs to see if it was sendmail that rejected it or the SMTPd.
"From: Symphonics <symphonics@inter.net>\r\n" works with my mail server however, which runs hMailServer on win32. _________________
|
|
Back to top |
|
|
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Fri Jun 16, 2006 12:25 pm Post subject: |
|
|
A friend got it working, we're now able to spoof emails on our school network. :)
Here's the code:
Code: | <?php
$emailaddress="x@elev.it-gymnasiet.se";
$emailsubject="Vad säger du nu då n00b?";
$headers .= 'From: Anna Könberg'.$eol;
$msg = "LOLAD!";
ini_set(sendmail_from,'hehe@hehe.com');
mail($emailaddress, $emailsubject, $msg, $headers);
ini_restore(sendmail_from);
?> |
Credits to Ducken^. |
|
Back to top |
|
|
|