Jump to content

Recommended Posts

Posted

I am having a problem sending email through PHP's built-in mail function. I can send to my address at home, but not to my address with the domain i have hosted with you. Let's say my domain with you is "****".

 

here is my code:

>$from = "Webmaster";
$mailfrom = "sarah@****";
$emailto = "sarah@****";
$subject = "My Subject";
$message = "my message";
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ".$from." <".$mailfrom.">\r\n";
$headers .= "Reply-to: $mailfrom";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP4\n";

ini_set(sendmail_from,$mailfrom);

 if (@mail($email, $subject, $message, $headers)){
	 print "<a href='login.php'>Login</a><br>";
	 print "Your password was emailed to you. Please check your email within a few minutes.";
	 ini_restore(sendmail_from); 
 }
 else{
	 print "Your password could not be emailed.. Please contact your system admin or try again.";
	 exit;
 }

 

Can anyone help me identify what's going on? I tried everything, and I don't want to use someone else's code if there's a small fix. Please help!

 

Sarah

Posted

I've looked over your code and it looks well written. I've also used mail() to send email to me at whatever@mysite.com

 

The only thing I can think of...

 

1- Why are you using ini_set? I see what it does but maybe you could try commenting it out of you script to see if that helps.

 

2- Has your site fully propagated? Can you send email from your home account to you@yoursite.com?

 

If neither of those are the issue, then I'd submit a help ticket. There is a very small possiblity that something at the server level needs looking at. I ran into a similar issue and it turned out that the email server and my webserver were set differently.

 

TCH tech support is very good.

Posted

I'm receiving email fine if I send to myself from my home account. Maybe it has something to do with the MX record for my email being set to a different server than one at TotalChoice?

 

We are using our own email server, which has a Lotus Notes Email Program.

I can't imagine why else it wouldn't be working. I don't get any error messages.

 

I've taken out the ini_set commands, I was using it to set the mailfrom to make sure things would get there from me instead of the default "nobody". I guess I will submit a help ticket since I can't figure out what else to do.

 

Sarah

Posted

Apparently, the mail was going to my account on TCH locally, instead of directing it out to my own mail server, even though the MX records were pointing to the right server.

All the mail that was sent showed up in my webmail box!!

 

I submitted a help desk ticket and we got it straightened out. Now i'm trying to figure out how to make the "nobody@server29.totalchoicehosting.com" disappear from the "from" field.

 

Thanks for the help!

Posted

Ok,

I checked the thread and I understand that.. But how could I send all the other headers while putting that 4th parameter in?

 

Should i put:

>mail($mailto,$subject,$message,$headers,From: $mailfrom)

 

or something like that? I don't think it handles 5 parameters.

Posted

I got it!!!!!! YAYYA!

 

I read some posts on php.net and found that the "\r" only works for Windows-based servers using SMTP. (my old web host used that). So I took them out and added the From header and it worked!! Hooray!!

 

Here's the code:

>$mailfrom = "sarah@****";
$emailto = "sarah@****";
$subject = "subject";
$message = "message";
$headers = "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: $mailfrom\n";
$headers .= "Reply-to: $mailfrom\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-Mailer: PHP4\n";
 
if (@mail($emailto, $subject, $message, $headers)){
	 print "<a href='login.php'>Login</a><br>";
	 print "Your password was emailed to you. Please check your email within a few minutes.";

 }
 else{
	 print "Your password could not be emailed.. Please contact your system admin or try again.";
	 exit;
 }

 

Thanks everyone.

Rock Sign

PS - hey Rick, I have a parrot just like the one in your photo!

Posted

Yep, solved the nobody@serverXX.totalchoicehosting.com .

 

Hopefully this will help anyone else having the same problems.

 

C-ya around.

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...