Email script not working

fake01

New Member
Messages
24
Reaction score
0
Points
0
So I have an email script which sends a welcome email along with activation link after a user creates an account. However, the registration process works fine but no email get's sent. The script is:

PHP:
function sendWelcome($user, $actkey, $email){
      $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";
      $subject = "insight - Welcome!";
      $body = $user.",\n\n"
             ."Welcome! You've just registered at insight with the following information\n\n"
             ."Username: ".$user."\n"
             ."You must activate this account before you can use it. To do this click on\n"
             ."the link below.\n\n "
             ."http://insight.pcriot.com/activate.php?i=".$user."&id=".$actkey."\n\n"
             ."- insight";

      mail($email,$subject,$body,$from);
}
Is there something wrong with it? I've used it before when I first began creating the registration form and it worked. However since fixing a lot of it up it's stopped working. The script is executed with:

PHP:
 if(EMAIL_WELCOME){
               $mailer->sendWelcome($subuser, sha1($subuser.$subemail.DB_SALT), $subemail);
}
 

dibb3386

New Member
Messages
61
Reaction score
0
Points
0
Where you have '$from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";' LINE 2

Try change to:-

$from = "From: inSight <myemail@address.com>";
 

fake01

New Member
Messages
24
Reaction score
0
Points
0
Where you have '$from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">";' LINE 2

Try change to:-

$from = "From: inSight <myemail@address.com>";

Well after hours of testing I think I have figured it out. For some unknown reason everytime I put the email address as @gmail or @hotmail, it doesn't work. but I can use anything else like @example or @test etc and it works.

I just have no idea why. I have nothing on my script which tells it to prevent sending gmail or hotmail emails addresses. I can send to gmail or hotmail accounts, I just can't have my email address (for From: ) as a gmail or hotmail address.

Is mailer or something preventing me sending emails as my gmail or hotmail email address?

Edit:
OK, I can now confirm that anything ending with @gmail or @hotmail in the $from field will NOT send. This was not an issue before the server upgrades. Has something changed to do this?

I'm quite happy with the upgrade as phpMyAdmin works MUCH faster now and is easier to use. But it's a disappointment that the script won't work with @gmail or @hotmail.
 
Last edited:

xgreenberetx

New Member
Messages
57
Reaction score
1
Points
0
I'm guessing them sites black listed the domain, or x10 does not allow it using them email extensions.
 

fake01

New Member
Messages
24
Reaction score
0
Points
0
Any way to find out if x10hosting has blocked those extensions? and anyway to see how to unblock them?
 

rkalhans

New Member
Messages
33
Reaction score
1
Points
0
I guess i know the problem
They must be going to the spam mail box, (check for God's sake coz this is silly)
;)
moreover to sort out the problem, put the proper headers, check out some site with tutorials, I wont post in the link as some of the Admins here have problems with that (I dont know the reason).
and I guess you will be fyn.

If you find this post helpful try adding to my reputation, I have been doing this thankless job for a while now. :cool:
 

fake01

New Member
Messages
24
Reaction score
0
Points
0
I guess i know the problem
They must be going to the spam mail box, (check for God's sake coz this is silly)

That's also another weird problem, some go to spam others go to normal place. And yes I do check spam and I can assure you ANYTHING with @gmail or @hotmail will NOT send, either to spam or normal place, I've checked at leats 50 times over several hours after making adjustments etc.
;)

moreover to sort out the problem, put the proper headers, check out some site with tutorials, I wont post in the link as some of the Admins here have problems with that (I dont know the reason).

I don't need a tutorial on how to create an email script. I said the email script works and sends emails to email addresses. It just doesn't send them if I put the sender as @gmail or @hotmail (I haven't tried other email services).

Here:

PHP:
function sendWelcome($user, $actkey, $email){
      $from = "From: ".EMAIL_FROM_NAME." <".EMAIL_FROM_ADDR.">"; //THIS IS THE PROBLEM
      $subject = "insight - Welcome!";
      $body = $user.",\n\n"
             ."Welcome! You've just registered at insight with the following information\n\n"
             ."Username: ".$user."\n"
             ."You must activate this account before you can use it. To do this click on\n"
             ."the link below.\n\n "
             ."http://insight.pcriot.com/activate.php?i=".$user."&id=".$actkey."\n\n"
             ."- insight";

      mail($email,$subject,$body,$from);
}
If .EMAIL_FROM_ADDR. == anyname@gmail.com OR anyname@hotmail.com it will NOT send. However if I put it as anyname@lol.com or anyname@itworks.com or some other random thing it WORKS.

 

xgreenberetx

New Member
Messages
57
Reaction score
1
Points
0
Just put the name of your site for the from addy, and in the email message include the real email to reply to?
 

rkalhans

New Member
Messages
33
Reaction score
1
Points
0
Just put the name of your site for the from addy, and in the email message include the real email to reply to?
This has to be done using headers in the mail function (this and a few other modifications is what i wanted to refer to in my last post),

@fake01
I don't need a tutorial on how to create an email script.
Sure you don't need to write a script to send an email, but you do need to refer to some tutorials if you want to create an email script that's not blocked by Gmail and Hotmail, and that's not marked as spam. :cool:
All the best
 

fake01

New Member
Messages
24
Reaction score
0
Points
0
@fake01
Sure you don't need to write a script to send an email, but you do need to refer to some tutorials if you want to create an email script that's not blocked by Gmail and Hotmail, and that's not marked as spam. :cool:
All the best

Well I might as well mention also that I also used the email script from w3schools and got the exact same results;).
 

rkalhans

New Member
Messages
33
Reaction score
1
Points
0
Try this script

PHP:
<?php

$from = "you@domain.com";
$rec="reciever@hullabulla.com";//recievers address
$to = str_replace(" ","",$rec);
$subject = "Hi!";
$message = "Hi,\n\nHow are you?";
$host = "localhost";
$port = "25";
$username = "";//default for x10hosting 
$password = "";//default for x10 hosting
ini_set("SMTP",$host);
$headers = 'From: managersOfYourSite<you@domain.com>' . "\r\n" .
    'Reply-To: managersOfYourSite <you@domain.com>' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers))
echo "<h1>Sent</h1>";
 


?>

Thiis working and i used this to send mail to a gmail account, from an x10hosting server
Moreover, it came to the inbox and not in spam mail.

PROBLEM: The PHP MALER VERSION <Read more one some online tutorials (only if you need it)>

An advice/Request : If you are posting your problems to be solved, please try doing thing what ppl suggest, Noone has this much tym to sit and test all the scripts.
 
Last edited:

fake01

New Member
Messages
24
Reaction score
0
Points
0
Try this script

PHP:
<?php

$from = "you@domain.com"; //This part
$rec="reciever@hullabulla.com";//recievers address
$to = str_replace(" ","",$rec);
$subject = "Hi!";
$message = "Hi,\n\nHow are you?";
$host = "localhost";
$port = "25";
$username = "";//default for x10hosting 
$password = "";//default for x10 hosting
ini_set("SMTP",$host);
$headers = 'From: managersOfYourSite<you@domain.com>' . "\r\n" . //And this part
    'Reply-To: managersOfYourSite <you@domain.com>' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers))
echo "<h1>Sent</h1>";
 


?>
Thiis working and i used this to send mail to a gmail account, from an x10hosting server
Moreover, it came to the inbox and not in spam mail.

PROBLEM: The PHP MALER VERSION <Read more one some online tutorials (only if you need it)>

An advice/Request : If you are posting your problems to be solved, please try doing thing what ppl suggest, Noone has this much tym to sit and test all the scripts.

Try changing @domain to @gmail or @hotmail and see if it works. I will try also later as I got somewhere to be atm.
 

rkalhans

New Member
Messages
33
Reaction score
1
Points
0
Try changing @domain to @gmail or @hotmail and see if it works. I will try also later as I got somewhere to be atm.
Try changing @domain to @gmail or @hotmail and see if it works. I will try also later as I got somewhere to be atm.

Yeah i have tested it by sending it to @gmail.com recipient, thats what i have mentioned in my previous post,please read it properly before replying back.

And you cannot/should not send a mail using a gmail or hotmail id in the from and reply-to section. use an email id like "noreply@yourhost.com", whereas you can sent to a gmail or a hotmail account without any possible trouble.
 

fake01

New Member
Messages
24
Reaction score
0
Points
0
And you cannot/should not send a mail using a gmail or hotmail id in the from and reply-to section. use an email id like "noreply@yourhost.com", whereas you can sent to a gmail or a hotmail account without any possible trouble.

This is my problem right here. If I'm gonna build a website (for clan/team/guild purposes) and when the guy installs it on their domain and decides to use his email address at (hisname@gmail.com OR hisname@hotmail.com) so when he sends emails from the website to people, they can reply directly back to his email address.

However, he won't be able to do that if @gmail or @hotmail is filtered and cannot send. This whenever used to be a problem, so why now?
 

rkalhans

New Member
Messages
33
Reaction score
1
Points
0
This is my problem right here. If I'm gonna build a website (for clan/team/guild purposes) and when the guy installs it on their domain and decides to use his email address at (hisname@gmail.com OR hisname@hotmail.com) so when he sends emails from the website to people, they can reply directly back to his email address.

However, he won't be able to do that if @gmail or @hotmail is filtered and cannot send. This whenever used to be a problem, so why now?


I have a solution for that

use the gmail or the hotmail id in the reply to section

also you can use his anme in the from section so that that will be displayed to the reciever but do not use it in the from

thus your $header can be assigned the following value

PHP:
$headers = 'From: NameofTheUser<noreply@yourdomain.com>' . "\r\n" .t
    'Reply-To: NameofTheUser <UsersemailID@gmail or hotmail.com>' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();


this may also not the best solution as gmail/hotmail may block your mail (or put it in spam mails ) as this may be considered to be a spam attempt :)


To achieve what you want you should ask the user for his gmail/hotmail username and password and signin to gmail/hotmail using a script and then send a mail using gmail's smtp server (or just gmails sendmails API's, you may need to use AJAX). This is how this is done by most of the sites.

or you can try the above method but your site may be permanently blocked by gmail and hot mail for spamming and you may not be able to send any more mails to all the gmail and hotmail ids.
 
Last edited:

amtt8000

New Member
Messages
2
Reaction score
0
Points
0
Thank you both. For good question and good answer. Again I know a little more...
 

drf1229

New Member
Messages
71
Reaction score
1
Points
0
Try this script

PHP:
<?php

$from = "you@domain.com";
$rec="reciever@hullabulla.com";//recievers address
$to = str_replace(" ","",$rec);
$subject = "Hi!";
$message = "Hi,\n\nHow are you?";
$host = "localhost";
$port = "25";
$username = "";//default for x10hosting 
$password = "";//default for x10 hosting
ini_set("SMTP",$host);
$headers = 'From: managersOfYourSite<you@domain.com>' . "\r\n" .
    'Reply-To: managersOfYourSite <you@domain.com>' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers))
echo "<h1>Sent</h1>";
 


?>
Are the $username and $password parameters for this script your credentials to get into cpanel or are they smtp specific?
 
Top