a patch has been submitted to fix this in 5.4
(PHP 4, PHP 5)
imap_mail — Send an email message
This function allows sending of emails with correct handling of Cc and Bcc receivers.
bcc are all strings and are all parsed
as » RFC822 address lists.
The mail subject
The mail body
As string with additional headers to be set on the mail
The receivers specified in
bccwill get the mail, but are excluded from the headers.
Use this parameter to specify return path upon mail delivery failure. This is useful when using PHP as a mail client for multiple users.
TRUE on success or
FALSE on failure.
- mail() - Send mail
Note: this function is a local wrapper round sendmail (or the php win32 mail functions), rather than using the imap c-client smtp functionality to sendmail. Do not expect error handling by the c-client library to be returned by this as I did.
As per http://bugs.php.net/bug.php?id=30688 the $rpath argument is ignored, and since the (as of now) 4 year old bug is tagged WONTFIX in the bug tracker, this function is effectively deprecated in favour of mail().
make sure you've correctly setup the SMTP parameters in php.ini
and aslo make sure that the SMTP server accepts relay
for some mail servers, you have to open up an imap stream, log in, and then you can send mail through imap_mail
FYI, to finish your message post over telnet, enter a period (".") by itself as the last line of the post. Took me a while to google this so I thought I'd share. Then you can disconnect with 'quit'.
Extending the above note.
When the socket connection is stablished, it works exactly as if you had openned a telnet connection to the news server. If you don't know what kind of headers you have to send to the news server, then I'll suggest that you better give it a try and play with a telnet connection like this:
telenet news.servername.com 119
telnet news.euroconnect.dk 119
Connected to news.euroconnect.net (188.8.131.52).
Escape character is '^]'.
200 news.euroconnect.net (Typhoon v1.2.1)
then you'll receive confirmation from the server that you are connected. Now type "help" and enter, and you'll see what commands are supported.
100 Legal Commands
authinfo type value
list [active wildmat|active.times|counts wildmat]
list [overview.fmt|newsgroups wildmat]
newgroups yyyymmdd hhmmss [GMT]
newnews newsgroups yyyymmdd hhmmss [GMT]
xhdr field [range]
xpat field range pattern
If you want to post a message, you can start by entring the "post" command.
340 Send Article to be Posted
From here you can start to enter the header information.
The most important headers are:
after the ":" a "white space" must follow.
If you are posting the multipart message then remember
This one is also one of the important headers when you are posting a multipart message. The boundary must follow the content type in the same line.
Content-Type: multipart/mixed; boundary="------------4A11A9ABCFCA70DD4E0C3605"
Take a look at the article below to find out more about headers and packing of the message.
If you need to send messages to a NNTP server, and you don't find the function, which is sufficient for this job, then use this.
$stream = fsockopen($server,$port, &$errno, &$errstr);
fwrite($stream, "Newsgoups "$newsgroup."\n");
$fwrite ($stream, " What ever you need to write\n");
fwrite($stream, "The rest of what you like to write\n");
There are ofcourse not so straight, but if you know which parameters your message needs, you can do it like this.
You can build up a message with imap_mail_compose ();
When you a complete message then U can write it to the server, and the server will take care of the time, date, Massage-ID and so on, but you have to know the sturcture of the header which you make, and if you like to write a multipart message, then you better get to know it in details.
In case that you know a better way, please inform me.
You can change the From field in your message by specifying "From: firstname.lastname@example.org" in the additional_headers field.