Sending emails with my real name

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Thu Jun 15, 2006 9:16 pm    Post subject: Sending emails with my real name Reply with quote

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 View user's profile Send private message
lspence
-


Joined: 16 Jul 2004
Posts: 15

PostPosted: Thu Jun 15, 2006 10:03 pm    Post subject: Reply with quote

Try this...

"From: Password recovery <password@2q4u.com>"
_________________
Luke Spence - CJCA - Cracker Jack Collectors Association
Back to top View user's profile Send private message Visit poster's website
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Thu Jun 15, 2006 10:18 pm    Post subject: Re: Sending emails with my real name Reply with quote

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 View user's profile Send private message Visit poster's website
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Thu Jun 15, 2006 10:34 pm    Post subject: Re: Sending emails with my real name Reply with quote

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 View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Fri Jun 16, 2006 12:06 am    Post subject: Reply with quote

I /know/ using "From: Symphonics <symphonics@inter.net>\r\n" works.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Fri Jun 16, 2006 12:38 am    Post subject: Reply with quote

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 View user's profile Send private message
cyberstyles
-


Joined: 04 Jun 2006
Posts: 31

PostPosted: Fri Jun 16, 2006 9:12 am    Post subject: Reply with quote

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 View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Fri Jun 16, 2006 10:45 am    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Fri Jun 16, 2006 11:08 am    Post subject: Reply with quote

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 View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Fri Jun 16, 2006 12:16 pm    Post subject: Reply with quote

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 View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Fri Jun 16, 2006 12:25 pm    Post subject: Reply with quote

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 View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group