mail () and web server's issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
davenarc
Forum Newbie
Posts: 1
Joined: Sun Oct 26, 2003 8:01 am
Location: Malaysia
Contact:

mail () and web server's issue

Post by davenarc »

Code: Select all

$mailTo = "$To";
        $tafriend_to_name .= ",";
        $mailSubject = "$tafriend_subject";
        $mailBody .= "Dear $tafriend_to_name\n\n";
        $mailBody .= "You friend, $tafriend_from_name has sent you an invitation to visit http://www.thankyoumahathir.com.my, with the Personal Message below:\n\n";

        $mailBody .= "$tafriend_personal_message\n\n";
        $mailBody .= "Best Regards,\n";
        $mailBody .= "2mediastudio Management and Web Development Team\n";

        $mailHeaders = "From: $tafriend_from_name";

        mail($mailTo, $mailSubject, $mailBody, $mailHeaders);
[mod_edit:

Code: Select all

tag added][/size]

i used the above coding for sending the email, but it seem to be like only works for the sending to the mailbox that hosted within the same server or same mail server only.

but this code couldn't send the email when the $mailTo is send to outsider like yahoo or hotmail.

After i have check with our hosting provider they told us that 


"

The script tafriend.php is trying to use php's mail() function to send mail (using /usr/bin/sendmail), however with Apache running in a chrooted encvironment, from the web tafriend.php cannot access /usr/bin. The main directory (/) as Apache/tafriend.php sees it is actually /home/mydomain/public_html.
 

I would suggest using a function other than sendmail (perhaps create a socket to port 25 of 127.0.0.1 and send the mail manually), or follow suggestions from http://us4.php.net/manual/en/ref.mail.php.  I strongly suggest reading the post by "grey at greywyvern dot com" or "hzmz at bofh dot auca dot kg".

I'm not so familiar with Linux yet.

Hey dude, plz help me on these, i'm kinda new and now got a deadline to meet.........

Thanks alot in advance....................
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

the comment of grey at greywyvern dot com is a php function you can include in your own scripts to send mails without php's native mail() function. It requires php's socket extension but since you got note from your provider to use it, it seems sockets are enabled at your host.
The script's parameters are quite selfexplainary. Only thing it doesn't support are the additional headers. But you can change the script for your needs quite easily, add a new parameter and use it instead of the static strings in
fputs($connect, "From: My Name <myemail@address.com>\r\n");
fputs($connect, "To: $toKey <$toValue>\r\n");
fputs($connect, "X-Sender: <myemail@address.com>\r\n");
fputs($connect, "Return-Path: <myemail@address.com>\r\n");
fputs($connect, "Errors-To: <myemail@address.com>\r\n");
Post Reply