Page 1 of 1

mail () and web server's issue

Posted: Sun Oct 26, 2003 8:01 am
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....................

Posted: Sun Oct 26, 2003 9:39 am
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");