Solved

Can't send email

Posted on 2013-01-26
6
264 Views
Last Modified: 2013-01-27
Hi,

I have a weird problem.

I use the following function to send emails from my support form on my website, but it simply stopped working, no email is being received in my helpdesk from this form.

Have tried to send and email manually from my private email account to the same "receiver/helpdesk email" and it works fine.

So I wonder, is there an error in this coding (I removed the parameters for error checking)?
# Send email to contact
function contact() {

	$name = "Kenneth";
	$email = "my@email.com";
	$title = "A message";
	$message = "The message";

	# Send the email
	if(mail("mail@domain.com", $title, $message, "From: $name <$email>\nX-Mailer: PHP/" . phpversion())) {
		
		return true;
	}else{
	
		return false;
	}
}

Open in new window

0
Comment
Question by:kgp43
  • 3
  • 3
6 Comments
 

Author Comment

by:kgp43
ID: 38823601
Or can it be a server issue, not allowing me to send the form data to an external email account?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38823616
try this:
$name = "Kenneth";
	$email = "my@email.com";
	$title = "A message";
	$message = "The message";

	
$headers = "From: $name <$email>\r\nX-Mailer: PHP/".phpversion();

	# Send the email
	if(mail("mail@domain.com", $title, $message, $headers)) {

		return true;
	}else{
	
		return false;
	}
}

Open in new window


btw, are you using gmail address as sender?
also you might get filtered, is this your server? are you using paid mail server/host?
0
 

Author Comment

by:kgp43
ID: 38823623
Hi,

I't's not gmail. My own domain and own server.
The helpdesk settings etc are setup correctly (I can receive emails from all my private email accounts).

I will try what you suggested.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38823627
If firewall is enabled, check that firewall not filter the ports used to send the mail.
also check if your server has MTA (mail transfer agent) installed (windows based server doesn't have it as default)
0
 

Author Comment

by:kgp43
ID: 38823628
It works fine now, must be an issue with the helpdesk settings (zendesk).
Thanks for your help :)
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38823629
no problem, good luck.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wordpress Query 1 32
Mail Not Sent 6 42
How can I do this in Pyhton? 12 68
Converting SQL server date to string 3 15
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now