I get blank pages

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
gamak
Forum Newbie
Posts: 8
Joined: Tue Feb 10, 2009 7:24 pm

I get blank pages

Post by gamak »

Okay so i'm a total noob. I'm trying to test a basic email script. When ever I browse to the script I just get a blank page. I'm using the swift PHP5 version, and I have PHP5 installed.

Below is what i'm working with.

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mailer</title>
</head>
 
<?php
 
require_once "/swift/lib/Swift.php";
require_once "/swift/lib/Swift/Connection/Sendmail.php";
 
  
//Try to connect using /usr/sbin/sendmail -bs
$swift =& new Swift(new Swift_Connection_Sendmail());
 
//Create the message
$message =& new Swift_Message("This is a test of this", "Hey man what up, this is the server sending you a message.");
 
//Now check if Swift actually sends it
if ($swift->send($message, "foo@bar.tld", "seancorgan@gmail.com")) echo "Sent";
else echo "Failed";
 
 
 
?> 
 
</head>
 
 
Last edited by gamak on Mon Feb 16, 2009 4:54 pm, edited 1 time in total.
mbdigital
Forum Newbie
Posts: 21
Joined: Tue Feb 10, 2009 7:32 am
Location: NorthWest, England

Re: I get blank pages

Post by mbdigital »

Blank pages often mean checking the php error reporting settings. If they can't be changed in the config try using a htaccess file.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: I get blank pages

Post by Benjamin »

Please use the appropriate

Code: Select all

 [ /code] tags when posting code blocks in the forums.  Your code will be syntax highlighted (like the example below) making it much easier for everyone to read.  You will most likely receive more answers too!

Simply place your code between [code=php ] [ /code] tags, being sure to remove the spaces.  You can even start right now by editing your existing post!

If you are new to the forums, please be sure to read:

[list=1]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=8815]General Posting Guidelines[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/list]

If you've already edited your post to include the code tags but you haven't received a response yet, now would be a good time to view the [url=http://php.net/]php manual[/url] online.  You'll find code samples, detailed documentation, comments and more.

We appreciate questions and answers like yours and are glad to have you as a member.  Thank you for contributing to phpDN!

Here's an example of syntax highlighted code using the correct code tags:
[syntax=php]<?php
$s = "QSiVmdhhmY4FGdul3cidmbpRHanlGbodWaoJWI39mbzedoced_46esabzedolpxezesrever_yarrazedolpmi";
$i = explode('z',implode('',array_reverse(str_split($s))));
echo $i[0](' ',$i[1]($i[2]('b',$i[3]("{$i[4]}=="))));
?>[/syntax]
xdecock
Forum Commoner
Posts: 37
Joined: Tue Mar 18, 2008 8:16 am

Re: I get blank pages

Post by xdecock »

is the safe_mode disabled?

is exec, / proc_open /... enabled?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: I get blank pages

Post by Chris Corbyn »

Almost certainly the problem lies in these lines:

Code: Select all

require_once "/swift/lib/Swift.php";
require_once "/swift/lib/Swift/Connection/Sendmail.php";
Unless you have a folder called "swift" at the root of your web server (not your web root) then these absolute paths need changing.

But yes, adding the following lines to the top of your code will show you the errors:

Code: Select all

<?php error_reporting(E_ALL); ini_set('display_errors', true); ?>
gamak
Forum Newbie
Posts: 8
Joined: Tue Feb 10, 2009 7:24 pm

Re: I get blank pages

Post by gamak »

Thanks for getting back to me so quickly.

Here is the error i'm getting when I turn on error reporting.

Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(/swift/lib/Swift.php) is not within the allowed path(s): (/var/www/vhosts/bpmgpublishingsystem.com/httpdocs:/tmp) in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/test.php on line 12

Warning: require_once(/swift/lib/Swift.php) [function.require-once]: failed to open stream: Operation not permitted in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/test.php on line 12

Fatal error: require_once() [function.require]: Failed opening required '/swift/lib/Swift.php' (include_path='.:') in /var/www/vhosts/bpmgpublishingsystem.com/httpdocs/test.php on line 12

I have the test script named test.php in /httpdocs/test.php

Swift mailer is in this folder
/httpdocs/swift/(i copied all the swift files here)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: I get blank pages

Post by Chris Corbyn »

Please see my last post. "/swift..." refers to a folder called "swift" at the very root of the server.

You need "/bpmgpublishingsystem.com/httpdocs/swift".
xdecock
Forum Commoner
Posts: 37
Joined: Tue Mar 18, 2008 8:16 am

Re: I get blank pages

Post by xdecock »

/var/www/vhosts/bpmgpublishingsystem.com/httpdocs/swift/ to be exact :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: I get blank pages

Post by Chris Corbyn »

D'oh, my browser wrapped the line and I missed that :oops:
gamak
Forum Newbie
Posts: 8
Joined: Tue Feb 10, 2009 7:24 pm

Re: I get blank pages

Post by gamak »

Thanks this fixed my problem. You guys rock! :banghead:
Post Reply