Jump to content

How do you send a bad email, and how do you get the info back.


njdubois

Recommended Posts

We are on a shared host from godaddy.  Part of our service is sending emails out with data from a phone call.  Name, number, date and time.  Sometimes we attach the audio file.

 

We have suspicions that clients are not getting the emails.  For the few that have reported not getting the messages, we have had check spam filters and so on and have come up with nothing.  It seems they are just... not getting the message.

 

If our system/code is working right (and 9 out of 10 it is), them not getting the email is something on their end.  I was talking to godaddy today and the rep said that if the email relay has an issue it will bounce the email back.  When I asked where it gets bounced back to, he confirmed that it was the from address.  Using my email as the from address and sending an email to "bobthebuilder@somerandomwebsiteoutthere.com," using our webform, I get nothing about a bad email.

 

In gmail itself, if I send an email to "bobthebuilder@somerandomwebsiteoutthere.com" I get an email right away saying the domain doesn't exist.

 

This is the code that sends emails:

	if($file_name[0]=='') {

		$headers = 'From: ' . $MSG_row['from_email'] ."\r\n".
		'Reply-To: ' . $MSG_row['from_email'] ."\r\n" .
		'MIME-Version: 1.0' . "\r\n" .
		'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
		'X-Mailer: PHP/' . phpversion();


		$mail_sent = @mail($to, $MSG_row['msg_subject'], $email_message, $headers);
	}
	else {
		
		$headers = "From: " . $MSG_row['from_email'];
 
		// boundary 
		$semi_rand = md5(time()); 
		$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
 
		// headers for attachment 
		$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; 

		// multipart boundary 
		$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n"; 
		$message .= "--{$mime_boundary}\n";
 
		// preparing attachments
		$main_path='email_upload/';

		for($x=0;$x<count($file_name);$x++){
			$file = fopen($main_path.$file_name[$x],"rb");
			$data = fread($file,filesize($main_path.$file_name[$x]));
			fclose($file);
			$data = chunk_split(base64_encode($data));
			$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$file_name[$x]\"\n" . 
			"Content-Disposition: attachment;\n" . " filename=\"$file_name[$x]\"\n" . 
			"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
			$message .= "--{$mime_boundary}\n";
		} 

		// send 
		$mail_sent = @mail($to, $MSG_row['msg_subject'], $message, $headers); 
	}

if they are not sending an attachment, $file_name[0] will = nothing.  Please keep in mind that we send way more emails out without files attached.  Those are typically the messages we are questioning.  Thought it could be happening to the attachment part of the code as well, we have not heard anything about those emails.

 

How would I format this code, so that problematic emails that the godaddy relay sends back, gets sent to someone?  I thinking, if its me on the email form sending a message, the problematic message should be sent to my email address.

 

$MSG_row['from_email'] would hold that email address.

 

I have read up on a few different email plug ins.  I am planning on looking into those in the future, I'm concerned that I wont be able to "install" it on a shared server and would prefer to find a way to make what I have work.

 

Also, is there any other way to cause an email to be bounced back?  For example sending to a bad domain, or sending with a very large attachment.

 

Any advice is greatly appreciated!  Thanks for your time!

 

Nick

 

Link to comment
Share on other sites

Email issues can be very difficult to debug. In addition to making sure all the proper headers are included, one possible issue is the domain of the from address and the sending email server. You are apparently sending the email through GoDaddy. But, is the GoDaddy server the authoritative email server for the domain used in the From address?

 

For example, if you send the emails using "me@mydomain.com", the DNS records for that domain should specify what SMTP server is used for that domain. If that SMTP is not the GoDaddy SMTP server this could cause problems for some recipients.

 

Some email server, upon receiving an email from an outside source will do a sort of reverse lookup to see if the domain used for the sender is valid for the SMTP server that sent the email. If not, the email may be dropped completely. No response to the intended recipient and no bounce-back to the originating email server or From addressee.

Link to comment
Share on other sites

Your should be using a php mail library to ensure all the proper headers and other important things are being sent.  I ran into a similar issue with my website and once I started unsing the phpmailer library I was getting almost 100% success rate on delivery.

 

I have downloaded and setup phpmailer, and already it seems better.  thanks!

 

Email issues can be very difficult to debug. In addition to making sure all the proper headers are included, one possible issue is the domain of the from address and the sending email server. You are apparently sending the email through GoDaddy. But, is the GoDaddy server the authoritative email server for the domain used in the From address?

 

For example, if you send the emails using "me@mydomain.com", the DNS records for that domain should specify what SMTP server is used for that domain. If that SMTP is not the GoDaddy SMTP server this could cause problems for some recipients.

 

Some email server, upon receiving an email from an outside source will do a sort of reverse lookup to see if the domain used for the sender is valid for the SMTP server that sent the email. If not, the email may be dropped completely. No response to the intended recipient and no bounce-back to the originating email server or From addressee.

 

In one area I am sending a message with a from address/reply to containing a non existent domain!  There is some awesome pointers in here, and as I setup this email library I am going to keep these things in mind.  Thanks!

Link to comment
Share on other sites



1. Use some php mail library to do this, as @fastsol said phpmailer is just fine or personally, I prefer swiftMailer.


 


2. You should buy a unique IP address for our shared hosting (GoDaddy provides that). That means, nobody with any other accounts on the same server could use this IP even you're sharing the same DNS and DNS records are being propagated somehow on the web.

Link to comment
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.