Jump to content

Archived

This topic is now archived and is closed to further replies.

SenenCito

mail problem

Recommended Posts

Good day please excuse my extremely rude way of registering to the forums and immediatly posting a help topic, this problem has me losing more hair daily and my web administrator seems to believe the problem is in the code, after trying and trying I would like to see if you guys can help me nail down the exact cause of the problem.

Its quite simple, I cant send email, in trying and trying I cut down the code to the bare and to just an example...currently this is the code


hmm for some reason I cant post the code, its actually really small

well this is frustrating, I cant post the code, it gives me an error and just wont let me post.., its only like 7 lines long, is there a defense against code posting in this forums? I didnt think I read that in the posting guidelines

Share this post


Link to post
Share on other sites

Another example of sending a utf-8 HTML mail:

[code]

$to = 'bob@barnyard.com';
$subject = 'Wakeup bob!';
$message = '<b>yo</b>, whassup?';
$headers = "From: server@barnyard.com\r\n" .
       'X-Mailer: PHP/' . phpversion() . "\r\n" .
       "MIME-Version: 1.0\r\n" .
       "Content-Type: text/html; charset=utf-8\r\n" .
       "Content-Transfer-Encoding: 8bit\r\n\r\n";

// Send
mail($to, $subject, $message, $headers);

[/code]

Good luck

The link for mail
[a href=\"http://uk.php.net/manual/en/ref.mail.php\" target=\"_blank\"]http://uk.php.net/manual/en/ref.mail.php[/a]

Share this post


Link to post
Share on other sites
[!--quoteo(post=388247:date=Jun 26 2006, 06:44 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Jun 26 2006, 06:44 PM) [snapback]388247[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Another example of sending a utf-8 HTML mail:

[code]

$to = 'bob@barnyard.com';
$subject = 'Wakeup bob!';
$message = '<b>yo</b>, whassup?';
$headers = "From: server@barnyard.com\r\n" .
       'X-Mailer: PHP/' . phpversion() . "\r\n" .
       "MIME-Version: 1.0\r\n" .
       "Content-Type: text/html; charset=utf-8\r\n" .
       "Content-Transfer-Encoding: 8bit\r\n\r\n";

// Send
mail($to, $subject, $message, $headers);

[/code]

Good luck

The link for mail
[a href=\"http://uk.php.net/manual/en/ref.mail.php\" target=\"_blank\"]http://uk.php.net/manual/en/ref.mail.php[/a]
[/quote]

ok that is almost about the exact code I have, its a basic example code, Ive put the code in my personal server and the server im workign on and ive included a phpinfo echo to see if anyone can help me spot why it isnt sending

[a href=\"http://senencito.com/gm/test.php\" target=\"_blank\"]http://senencito.com/gm/test.php[/a]

[a href=\"http://www2.royalmotorspr.com/test.php\" target=\"_blank\"]http://www2.royalmotorspr.com/test.php[/a]

Share this post


Link to post
Share on other sites
[!--quoteo(post=388467:date=Jun 27 2006, 08:09 AM:name=SenenCito)--][div class=\'quotetop\']QUOTE(SenenCito @ Jun 27 2006, 08:09 AM) [snapback]388467[/snapback][/div][div class=\'quotemain\'][!--quotec--]
ok that is almost about the exact code I have, its a basic example code, Ive put the code in my personal server and the server im workign on and ive included a phpinfo echo to see if anyone can help me spot why it isnt sending

[a href=\"http://senencito.com/gm/test.php\" target=\"_blank\"]http://senencito.com/gm/test.php[/a]

[a href=\"http://www2.royalmotorspr.com/test.php\" target=\"_blank\"]http://www2.royalmotorspr.com/test.php[/a]
[/quote]
On the first server, register_globals is ON (old, outdated, potentially dangerous), whereas on the second server register_globals is OFF. The difference is that on the second server you need to retrieve information passed (by URL or form) from the $_GET or $_POST array rather than just expecting the variables to be there. For example:
[code]<?php
$my_name = $_POST['my_name']; // retrieve my_name via POSTed form[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=388470:date=Jun 27 2006, 08:17 AM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 27 2006, 08:17 AM) [snapback]388470[/snapback][/div][div class=\'quotemain\'][!--quotec--]
On the first server, register_globals is ON (old, outdated, potentially dangerous), whereas on the second server register_globals is OFF. The difference is that on the second server you need to retrieve information passed (by URL or form) from the $_GET or $_POST array rather than just expecting the variables to be there. For example:
[code]<?php
$my_name = $_POST['my_name']; // retrieve my_name via POSTed form[/code]
[/quote]


that I was aware off, but I dont believe any of that actually impacts this code, since im not referencing variables nor using global variables, in it , this is the exact code

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--][code]$to      = 's.llanos@royalmotorspr.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
   'Reply-To: webmaster@example.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

if ( mail  ( $to, $subject, $message, $headers ) ){
  echo "email has been sent<br><br>";
}else{
echo "email <strong>hasnt</strong> been sent<br><br>";
}


echo phpinfo ( );
[/code][/quote]

Share this post


Link to post
Share on other sites
And that isn't sending the email? Make sure you check that emails are not being sent to your Junk/spam folders as emails sent with PHP usually get treated as spam.

Also make sure the server you are sending the email from has an SMTP server installed/configured. Otherwise no emails will be sent, regardless of what your if statement returns. Mail doesnt check the success of the email, it just checks that your have filled in the parameters correctly.

Share this post


Link to post
Share on other sites
[!--quoteo(post=388590:date=Jun 27 2006, 02:14 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 27 2006, 02:14 PM) [snapback]388590[/snapback][/div][div class=\'quotemain\'][!--quotec--]
And that isn't sending the email? Make sure you check that emails are not being sent to your Junk/spam folders as emails sent with PHP usually get treated as spam.

Also make sure the server you are sending the email from has an SMTP server installed/configured. Otherwise no emails will be sent, regardless of what your if statement returns. Mail doesnt check the success of the email, it just checks that your have filled in the parameters correctly.
[/quote]


I already checked if it was junk mail, nothing. from the phpinfo it looks like SMTP is installed but I will ring once again the web host and bother him some more to see if it is indeed correctly configured, any other way to check that?

and if mail just checks if the parameters are correct, then why is the exact same code on extremely similar versions of php behaving differently..I dont know its really driving me nuts

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.