Jump to content

Recommended Posts

I have Gallery2 installed on my server and it lets you register a user which emails you a message for verification.  I've tried creating a user based website of my own from scratch.  I've tried using the following code to test if the mail() function of PHP is working.

<?php
$to="[i]my email address here[/i]";
$subject="Test mail";
$message="Hello! This is a simple email message.";
$from="someonelse@example.com";
$headers="From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>

If I run the file, Mail Sent. is displayed, but no email is received.  Gallery2 works fine, so either the mail function of php is working, but my code is wrong or Gallery2 uses other means of sending it's email.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/105819-php-mail-finction/
Share on other sites

First, try this and tell us what happens.

 

<?php
$to="[i]my email address here[/i]";
$subject="Test mail";
$message="Hello! This is a simple email message.";
$from="someonelse@example.com";
$headers="From: $from";
$bool = mail($to,$subject,$message,$headers);
if ($bool) {
echo "Mail Sent.";
} else {
echo "Mail Not Sent.";
}
?>

 

mail() returns a boolean. TRUE if the sending was successful and FALSE if not. make sure it's executing successfully.

Link to comment
https://forums.phpfreaks.com/topic/105819-php-mail-finction/#findComment-542317
Share on other sites

@darkwater: I'm not getting defensive. I was just trying to clarify too. Too bad you can't read tone from words ;) Maybe I should use more wink faces when I type.

 

@op: So you added the italics after the fact just for the sake of showing in the post? They are not in your code that you're running when trying to send the mail? Does your host allow you to send mail? I heard a crazy story about a hosting company not letting anyone use the mail function.

Link to comment
https://forums.phpfreaks.com/topic/105819-php-mail-finction/#findComment-542366
Share on other sites

Nope the and are not in the code I'm running. In regards to my host letting me send mail, I'm assuming I can as I have Gallery2 in stalled and it uses a user registration system that sends the user an email for activating their account.  Gallery2 is on the same server, and it works for Gallery2, so either my code is wrong or Gallery2 sends mail via other means.

Link to comment
https://forums.phpfreaks.com/topic/105819-php-mail-finction/#findComment-542391
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.