icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » PHP mailing question

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old February 26th, 2008, 1:09 AM   #1 (permalink)
Registered User
Fresh Surpasser
 
Joined in Feb 2008
9 posts
Gave thanks: 0
Thanked 0 times
PHP mailing question

Hi everyone.

I've got what is probably an easily answered question, so I thought it better to ask here than get the help desk involved.

I've installed Drupal on my site, and I've noticed that it doesn't seem to be sending out emails. I started looking into the cause of this with Drupal, and the general consensus there seems to be that there's some problem with my PHP setup that causes this.

To test it out, I found this script online:
PHP Code:
<?php
// The message
$message "Line 1\nLine 2\nLine 3";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message wordwrap($message70);

// Send
$rc mail('my email address (edited to avoid spam)''Test Subject'$message);

if (
$rc) {
  print 
"Mail successfully sent!<br>";
}
else {
  print 
"Failed to send mail<br>";
}
?>
I've run that from my site multiple times, but I've never actually received the email at the intended address.

I'm starting to think there might be something wrong in my php.ini (I'm using this: http://surmunity.com/images/thephp5%21/php.ini)

Anyone know if there's anything else I'm supposed to set up to make this work correctly? I've never really done anything with PHP, so I've got no idea how to configure the ini correctly.

Thanks!
Ecrofirt is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2008, 11:21 AM   #2 (permalink)
URB4N 5K1LLZ
Super #1
 
Roxy's Avatar
 
Joined in Sep 2005
Lives in Orlando, FL
Hosted on SH63
2,656 posts
Gave thanks: 81
Thanked 128 times
I'm confused myself too. I've worked and edited a PHP mail form before, but not for Drupal. Is that the exact coding from Drupal, or something you added on your own? If anything I can give you a working PHP mail form with PHP and HTML included? Of course this is a last resort if someone else has the answer to this. =)
__________________
Roxanne


Urban Roxy -Personal Blog
SH63 - the best darn shared server!
Roxy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2008, 11:59 AM   #3 (permalink)
Surpass Fan
On a golden path...
 
Neil's Avatar
 
Joined in Oct 2004
Lives in UK
356 posts
Gave thanks: 6
Thanked 13 times
I have seen it before where it php mail (not just in drupal) failed to send mail but only with a specific set of circumstances, which were that you were sending to more than one email address (cc/bcc did not matter) and if any account was on the same server then it failed for all.
eg. message to cd.com;ef.com.... will not be received if d.com or e.com are on the same server.
__________________
D17/D21/P59/P62/VPSX - "Faith can move mountains" (Faiths a big girl....) - I'm not paranoid, I know they are out to get me!
Neil is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2008, 12:49 PM   #4 (permalink)
Surpass Fan
On a golden path...
 
Neil's Avatar
 
Joined in Oct 2004
Lives in UK
356 posts
Gave thanks: 6
Thanked 13 times
The method I use for mail is usually in the form;
// compile the email
if (mail($mail_to, $mail_subject, $mail_message, $mail_header, "-f $mail_email"))
{
$email_sent=true;
}
else
{
$errors[] =$msg_mailserver;
$email_sent=false;
}
}

if (isset($errors))
{

// if there were errors, list them
__________________
D17/D21/P59/P62/VPSX - "Faith can move mountains" (Faiths a big girl....) - I'm not paranoid, I know they are out to get me!
Neil is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2008, 1:02 PM   #5 (permalink)
URB4N 5K1LLZ
Super #1
 
Roxy's Avatar
 
Joined in Sep 2005
Lives in Orlando, FL
Hosted on SH63
2,656 posts
Gave thanks: 81
Thanked 128 times
I use this. For the PHP Code its:
PHP Code:
<?php
if(isset($_POST['submit'])) {

$to "youremail@address.com";
$subject "Subject of email here";
$name_field $_POST['name'];
$email_field $_POST['email'];
$url_field $_POST['url'];
$message $_POST['message'];

$headers "From: $email_field" "\r\n" .
    
"Reply-To: $email_field" "\r\n" .
    
'X-Mailer: PHP/' phpversion();

$body "From: $name_field\n E-Mail: $email_field\n Site URL: $url_field\n Tutorial Suggestion: $message\n";
 
echo 
"Data has been submitted to $to!";
mail($to$subject$body$headers);

} else {

echo 
"blarg!";

}
?>
Then the HTML coding is:
Code:
<form method="POST" action="mailer.php">
<INPUT TYPE="hidden" NAME="to" VALUE="youremailaddresshere">

<INPUT TYPE="hidden" name="subject" VALUE="Subject here">
<INPUT TYPE="hidden" NAME="form" VALUE="url for code">
<INPUT TYPE="hidden" NAME="admin" VALUE="your email address">
<INPUT TYPE="hidden" NAME="language" VALUE="en">
<p>
Name:<br>
<input type="text" name="name" value="" size=30>
<br>
Email:<br>
<input type="text" name="email" value="" size=30>
<br>
Site Url:<br>
<input type="text" name="url" value="" size=30>
<br>
Suggest a Tutorial:<br>
<textarea name="message" rows="6" cols="40"></textarea>
<br><br>
   <input type="submit" value="Submit" name="submit">
   <input name="Clear" type="reset" value="Clear" />
</form>
of course you would change around what you want shown for the input fields and what not. Also make sure to name your php mailer.php or whatever you need to be. Then change it in your HTML coding at the top to what the new PHP code file's name is.
__________________
Roxanne


Urban Roxy -Personal Blog
SH63 - the best darn shared server!
Roxy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2008, 4:17 PM   #6 (permalink)
Surpass Developer
On a golden path...
 
Mark's Avatar
 
Joined in Jan 2004
Lives in Florida
Hosted on decc.surpasshosting.com
493 posts
Gave thanks: 17
Thanked 76 times
Ecrofirt

If your server is running Cpanel/WHM: Did you disable nobody emails from Tweak Settings? If you did, then they won't get sent. Also, check /var/log/exim_mainlog for the subject you are sending and see if you notice any entries. If there was an error, it should tell you in there

Roxy, sanitize your inputs or I'm gonna spam the crap out of all of your forms
__________________
Mark
Surpass Hosting Developer
sɹnoʎ uɐɥʇ ɹǝʇʇǝq sı bıs ʎɯ
Mark is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old February 26th, 2008, 4:51 PM   #7 (permalink)
URB4N 5K1LLZ
Super #1
 
Roxy's Avatar
 
Joined in Sep 2005
Lives in Orlando, FL
Hosted on SH63
2,656 posts
Gave thanks: 81
Thanked 128 times
Quote:
Originally Posted by Mark View Post
Roxy, sanitize your inputs or I'm gonna spam the crap out of all of your forms
YES SIR!
__________________
Roxanne


Urban Roxy -Personal Blog
SH63 - the best darn shared server!
Roxy is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 11th, 2008, 12:50 PM   #8 (permalink)
Registered User
Fresh Surpasser
 
Joined in Feb 2008
9 posts
Gave thanks: 0
Thanked 0 times
Sorry it's taken me a bit to get back to this thread. I've been very busy with work and haven't had a chance to make my way back here.

Roxy, to answer your question:
When I went to Drupal's support forums regarding the issue, i found posts similiar to mine where people were given the text script I posted to test whether or not the mail() function was working on their server.

Apparently Drupal uses PHP's mail() function to send out emails, which is why people are given the script I posted as a stand-alone test.

I've noticed that I'm getting kickbacks at my admin email whenever I try to send a mail out with PHP. here's an example:

Quote:
This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

***yahoo.com
unrouteable mail domain "yahoo.com"

------ This is a copy of the message, including all the headers. ------

Return-path: <smoothjash136.surpasshosting.com>
Received: from smoothja by sh136.surpasshosting.com with local (Exim 4.66)
(envelope-from <smoothjash136.surpasshosting.com>)
id 1JSLRZ-0006vs-C9
for ***yahoo.com; Thu, 21 Feb 2008 19:07:13 -0500
To: ***yahoo.com
Subject: Account details for Bluesie Joe at Smooth Jams 104
X-PHP-Script: *** for 66.71.97.114
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal
Errors-To: admin***.com
Reply-To: admin***.com
From: admin***.com
Message-Id: <E1JSLRZ-0006vs-C9sh136.surpasshosting.com>
Date: Thu, 21 Feb 2008 19:07:13 -0500

Bluesie Joe,

Thank you for registering at ***. You may now log in to
**EDITED** using the following username and password:

username: **EDITED**
password: **EDITED**

You may also log in by clicking on this link or copying and pasting it in
your browser:

**URL EDITED OUT***

This is a one-time login, so it can be used only once.

After logging in, you will be redirected to
**URL EDITED OUT**
so you can change your password.


-- *** team
So it seems like it's a definite problem. Again though, I don't know if there's something screwed up in my php.ini or what have you. I'm using the PHP.ini you linked me to.

---

Mark: I've got a CPanel backend for my site, but I have no idea how to tweak my setup so I can disable nobody emails. If you can point me to where to check, though, I'll do that.

Last edited by Ecrofirt; March 11th, 2008 at 12:52 PM.
Ecrofirt is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old March 11th, 2008, 12:58 PM   #9 (permalink)
Surpass Developer
On a golden path...
 
Mark's Avatar
 
Joined in Jan 2004
Lives in Florida
Hosted on decc.surpasshosting.com
493 posts
Gave thanks: 17
Thanked 76 times
Looks like yahoo might have blacklisted mail from sh136's ip. I will have one of the abuse team look into it. Yahoo tend to be a nazis when it comes to their block lists however
__________________
Mark
Surpass Hosting Developer
sɹnoʎ uɐɥʇ ɹǝʇʇǝq sı bıs ʎɯ
Mark is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On