Welcome! Log In Create A New Profile

Advanced

Emailing issues - Help!!!

Posted by DesmondMpofu 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Emailing issues - Help!!!
September 16, 2011 04:09PM
The following emai code gives me the errors shown below
Language: PHP
<html> <head> <title>Mail Sent!</title> </head> <body> <?php                 $to = $_POST["to"];                 $from = $_POST["from"];                 $subject = $_POST["subject"];                 $message = $_POST["message"];                 $headers = "From: " . $from . "\r\n";                 $mailsent = mail($to, $subject, $message, $headers);   if ($mailsent) { echo "Congrats! The following message has been sent: <br><br>"; echo "<b>To:</b> $to<br>"; echo "<b>From:</b> $from<br>"; echo "<b>Subject:</b> $subject<br>"; echo "<b>Message:</b><br>"; echo $message; } else { echo "There was an error..."; } ?> </body> </html>

and the related form
Language: PHP
<html> <head> <title>Enter E-mail Data</title> </head> <body> <form name="theform" method="post" action="sendmail.php"> <table border ="1">                 <tr>                                 <td>To:</td>                                 <td><input type="text" name="to" size="70"></td>                 </tr>                   <tr>                                 <td>From:</td>                                 <td><input type="text" name="from" size="70"></td>                 </tr>                   <tr>                                 <td>Subject:</td>                                 <td><input type="text" name="subject" size="70"></td>                 </tr>                   <tr>                                 <td valign="top">Message:</td>                                 <td><textarea cols="60" rows="10" name="message">Enter your message here</textarea>                                                 </td>                 </tr>                   <tr>                                 <td></td>                                 <td><input type="submit" value="Send">  <input type="reset" value="Reset the form">                                 </td> </tr> </table> </form> </body> </html>

giving me this error:

Warning: mail() [function.mail http://127.0.0.1/mixed/function.mail ]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\EasyPHP-5.3.3\www\mixed\sendmail.php on line 12
There was an error...:

Now im not so sure what is really wrong with my settings, any ideas
Re: Emailing issues - Help!!!
September 16, 2011 04:13PM
Any ideas with this kind of error on emailing scripts guys, the code I have works on one machine but doesnot on another....

Warning: mail() [function.mail http://127.0.0.1/mixed/function.mail ]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\Program Files\EasyPHP-5.3.3\www\mixed\sendmail.php on line 12
There was an error...
avatar
Mac
Re: Emailing issues - Help!!!
September 19, 2011 06:52AM
Please use formatted code tags to post code....

XAMPP cannot send mail.
avatar Re: Emailing issues - Help!!!
September 19, 2011 12:31PM
Will this make us lose marks mac ? cause mine also gives this error but that's because you can't send it from xampp on localhost.

student no: 77315138
avatar
Mac
Re: Emailing issues - Help!!!
September 19, 2011 02:28PM
No.... as long as the code is correct. A bit difficult to test if you cannot see the result I know, but the code is generally simple.

You can add an if/else

Language: PHP
if (mail($to, $subject, $body)) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); }

Depending on you coded the mail of course.

Point is, if the failed message is echoed, then it means at least your code was correct, else another error will be shown.
Re: Emailing issues - Help!!!
September 20, 2011 04:58PM
Thanx mac smile that comforts...
avatar Emailing issues - Help!!!
October 05, 2011 07:52PM
I tried testing out sending mail and it did not work. I thought the Mail Server came with Apache and php ready to use, but it does not. I searched for the sendmail program on my pc at /usr/sbin/sendmail and its not there so I installed postfix and setup the php.ini file's sendmail_path = /usr/sbin/sendmail.

Before the Mail Server is started it has to be setup first. Setting up postfix is a long arduous task. Any sugestions.

I also uploaded Chapter11's script firstmail.php to my account on the free web hosting area ueuo.com and tried testing sending mail to my email account at Webmail.co.za no luck?
avatar Re: Emailing issues - Help!!!
October 06, 2011 08:23AM
Hi Ash,

Normally with hosting you don't need to worry about setting up anything for sending emails most server's offer sendmail all you need to do is build the script that sends the email. Maybe the guys you have free hosting with doesn't offer sendmail I don't know smiling smiley

With regard to setting up sendmail or postfix it's very complicated !

Setting Up Email: A Sendmail HOWTO
Setting Up Email: A Postfix/Dovecot HOWTO

Try: x10hosting free hosting

Simple Email Script:

Language: PHP
<?php   $to_email = "to@domain.co.za"; $from_email = "from@domain.co.za"; $message = "Test Email";   if (mail($to_email , "Email Subject", $message, "From: $from_email")) { echo("<p>Email successfully sent !</p>"); } else { echo("<p>Email delivery failed...</p>"); }   ?>

If it still doesn't work you can look at PHPMailer

student no: 77315138
avatar
Mac
Re: Emailing issues - Help!!!
October 06, 2011 10:27AM
Do not forget that in order for mail to be sent an received, you need to have a server-client setup. You have the server bit where is the mail sent to? You need to have an active Internet connection, a networked setup with another PC, or your code needs to run on a live server. Forget about sending and receiving mail on your PC in the XAMPP environment. The effort is not wort it. As Riaz implies, test you mail applications on a free web hosting server if you must.
Re: Emailing issues - Help!!!
October 06, 2011 07:45PM
Hey Guys,

If you want to test your mail, (Mac please correct me if I'm wrong) grinning smiley
Go check out http://www.mailtraq.com.
Also in the beginner Php textbook Chapter 11, pg 326, on the top section of the page.

I Have been testing my mail through this so far, so good. thumbs up
Its not permanent but it will help you with your project ; )
avatar
Mac
Re: Emailing issues - Help!!!
October 07, 2011 07:36AM
A server requires a registered IP address - a domain - that is known on the WWW so that you can receive emails. If you can receive, you can also send.
You can sidestep having a domain by configuring XAMPP to connect to an ISP-account that you have, as explained here: http://roshanbh.com.np/2007/12/sending-e-mail-from-localhost-in-php-in-windows-environment.html. Of course you need to be connected to the Internet for it to work.

What I am saying is that configuring XAMPP to send and receive mail is not going to work unless you install XAMPP on a PC that is a registered server.
Installed on your PC XAMPP just provides you with Apache (minus a functional mail server), PHP and MySQL environment, allowing you to run and test your code.

mailtraq is jsut an alternative mail server to the one build into XAMPP. The same rules apply.
Re: Emailing issues - Help!!!
October 07, 2011 03:35PM
Thanks Mac thumbs up
avatar Emailing issues - Help!!!
October 08, 2011 10:51PM
I checked the phpinfo() for my account at http://www.freewebhostingarea.com and the sendmail program is setup by default.

<table border="1" cellpadding="5">
<tr><td colspan="3" align="center">Configuration PHP Core</td></tr>
<tr>
<td>Directive</td>
<td>Local Value</td>
<td>Master Value</td>
</tr>
<tr>
<td>sendmail_from</td>
<td>no value</td>
<td>no value</td>
</tr>
<tr>
<td>sendmail_path</td>
<td>/usr/sbin/sendmail -t -i</td>
<td>/usr/sbin/sendmail -t -i</td>
</tr>
</table>

I tested out sending the firstmail.php script again and it worked smile. I guess the response time is slow. The mail sent is from Apache &lt;apache@ueuo-freewebhostingarea-com.ueuo.com&gt;

Thanks for the help Mac and Riaz smiling smiley.
Re: Emailing issues - Help!!!
October 23, 2011 10:13PM
I tried using x10hosting as a free host to test out my e-mail functionality.

But I don't get the PHP mail() function to work.

PHP code:
Language: PHP
$headers = ';MIME-Version: 1.0';."\r\n"; $headers .= ';Content-type: text/html; charset=iso-8859-1';."\r\n"; $headers .= ';From: thinuss@tmsnyman.x10.mx';."\r\n";   if(mail("thinuss@gmail.com","PHPtest","test body",$headers)){   }

In the above thinuss@tmsnyman.x10.mx is an e-mail account I created as part of the x10hosting configuration. As you can see I am trying to send to my gmail account.

I get an return error message in my thinuss@tmsnyman.x10.mx inbox saying the following:

"Gid 26351 is not permitted to relay mail, or has directly called /usr/sbin/exim instead of /usr/sbin/sendmail."

Does anyone know what this mean? Did anyone have this same problem? Can anyone please help?

Thx

T
avatar
Mac
Re: Emailing issues - Help!!!
October 24, 2011 08:08AM
Not a code issue - a issue on their side. Google for "or has directly called /usr/sbin/exim instead of /usr/sbin/sendmail"
Re: Emailing issues - Help!!!
October 27, 2011 10:06PM
oh yes you can send mails with this webserver....need life environment...
Sorry, only registered users may post in this forum.

Click here to login