Solved

Can't send email

Posted on 2013-01-26
6
266 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mysql update statement 3 22
Advice and best practice  SQLite3 Database using PHP 2 47
Insert won't work due to space in column name 5 21
php simple error message 4 23
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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.

770 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