RussellNiiOdartei
IS-IT--Management
Hello,
I've recently had to upgrade my sendmail script on my website, due to tighter security. So I now have to use one which uses my SMTP information. My ISP directed me to a script - but as I have very limited knowledge of PHP - I am having some difficulties with it.
The first line of the script is
What is mail.php - is this another file somewhere within the PHP installation - or should the file that this code is in be called mail.php?
Secondly - what does this require_once actually do? Is it necessary?
When I run the script as it is, with this line - I get this error:
Warning: main(mail.php) [function.main]: failed to open stream: No such file or directory in /home/rgevans/public_html/event_signup/emailtest.php on line 246
Fatal error: main() [function.require]: Failed opening required 'mail.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/rgevans/public_html/event_signup/emailtest.php on line 246
When I run the script with require_once edited out I get the following error:
Fatal error: Undefined class name 'mail' in /home/rgevans/public_html/event_signup/emailtest.php on line 260
The first error would suggest to me that this is a file already installed - the second suggests that this is something created within the code - but again as I said - I'm a novice!
My actual code is below:
Thanks in advance for your time
I've recently had to upgrade my sendmail script on my website, due to tighter security. So I now have to use one which uses my SMTP information. My ISP directed me to a script - but as I have very limited knowledge of PHP - I am having some difficulties with it.
The first line of the script is
Code:
require_once "mail.php";
What is mail.php - is this another file somewhere within the PHP installation - or should the file that this code is in be called mail.php?
Secondly - what does this require_once actually do? Is it necessary?
When I run the script as it is, with this line - I get this error:
Warning: main(mail.php) [function.main]: failed to open stream: No such file or directory in /home/rgevans/public_html/event_signup/emailtest.php on line 246
Fatal error: main() [function.require]: Failed opening required 'mail.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/rgevans/public_html/event_signup/emailtest.php on line 246
When I run the script with require_once edited out I get the following error:
Fatal error: Undefined class name 'mail' in /home/rgevans/public_html/event_signup/emailtest.php on line 260
The first error would suggest to me that this is a file already installed - the second suggests that this is something created within the code - but again as I said - I'm a novice!
My actual code is below:
Code:
<?php
#require_once "mail.php";
$from = "Ment2Excel Guest List <guestlist@ment2excel.com>";
$to = $email;
$subject = "Ment2Excel Guest List Registration";
$body = "Hi,\n\nHow are you?";
$host = "mail.XXX.com";
$username = "test@XXX.com";
$password = "XXXXX";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
Thanks in advance for your time