m2e Posted November 21, 2008 Share Posted November 21, 2008 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 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: <?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. Quote Link to comment https://forums.phpfreaks.com/topic/133620-sending-mail-phpsmtppear/ Share on other sites More sharing options...
JasonLewis Posted November 21, 2008 Share Posted November 21, 2008 Leave the line intact. If you've been directed to a script then you should've also received a file called mail.php. The first error is saying that it couldn't find that file 'mail.php', which should be in the same directory as the file that calls mail.php The second error is because, well, mail.php isn't included and it would seem to contain a class called mail, which it cannot use because the file mail.php can't be found. Quote Link to comment https://forums.phpfreaks.com/topic/133620-sending-mail-phpsmtppear/#findComment-695167 Share on other sites More sharing options...
m2e Posted November 21, 2008 Author Share Posted November 21, 2008 Thank you - I got the script from a website - so there was no mail.php attached - I guess I need to find the path for this from my hosting provider and hopefully that should solve it. Will do that and let you know how I get on. Thanks, Quote Link to comment https://forums.phpfreaks.com/topic/133620-sending-mail-phpsmtppear/#findComment-695286 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.