Sending email problem

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
stevan
Posts: 7
Joined: Thu Feb 09, 2006 10:34 pm

Sending email problem

Post by stevan »

Script URL:http://www.cruisevacationcenter.net/hesk/index.php
Version of script: 0.93.1
Version of PHP:
Hosting company: Tengun
Have you searched THIS FORUM for your problem:yes
(if not please do before posting)
If so, what terms did you try: email sending

Write your message below:

The script has been working great . Then about a week agoit will not send anything. I checked all and seems fine. Emailed by Hosting Co. and they said this I have posted below . It seems like they made a change to soemthing in there email servers. DO yuo agree >>> None of my php scripts will send . I can not have one that i use changed as it belongs to the cruise lines. DO you have any ideas or should i just chnage host. THXS for any suggestions . You have been very helpfull in the past

STEVE


Hi,



I believe the problem is that the mail server is rejecting certain script mail that is improperly formatted. When sending from a script, the "from" address must be a local domain (i.e., something@yourdomain.com). If calling sendmail directly, you can specify this with the "-f" parameter. With PHP's mail() function, you'll need to use the aditional parameter option like so:



mail("recipient@somewhere.com", "subject", "body", null, "-fsomething@yourdomain.com");



This is to help prevent insecure scripts from being exploited for spamming. Thanks,
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Hi,

In that case just make sure $hesk_settings['noreply_mail'] in hesk_settings.inc.php is set to a LOCAL e-mail (your domain cruisevacationcenter.net), for example:

$hesk_settings['noreply_mail']='something@cruisevacationcenter.net';

Regards,
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
stevan
Posts: 7
Joined: Thu Feb 09, 2006 10:34 pm

Post by stevan »

I has been set like that since I installed the script. I have no Idea what they are doing BUT since none of my php email scripts are not working off my site and I have a cruise booking engine that works that way and will not send information to cruise lines I am losing money every day . I am going to have to switch host I quess I see no other option. What ever they have done even affected my CGI script


THXS again for help

STEVE
GH
Posts: 4
Joined: Tue Apr 04, 2006 10:01 am

Same problem - no obvious solution

Post by GH »

Having the same problem. Script was running fine for a while now the emails are not being sent. The params for email addresses in settings file are the same local addresses they always were. What could be the problem?

Using a large host with standard up to date windows server installation and latest version of Hesk.
stevan
Posts: 7
Joined: Thu Feb 09, 2006 10:34 pm

Post by stevan »

I solved my problem by switchning hosts . They did something to the mail server and they would not change it so I could use scripts
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Yes, unfortunately this is what some hosts do, they don't allow sending mail from script for "security reasons".

If not already you can try switching your e-mail to a local address (e-mail address under the same domain as your Hesk installation is). Apart from that I cannot be of any help as Hesk uses the standard PHP mail() function and your host has the complete control over what they (not) allow when sending e-mails and from where.

http://www.phpjunkyard.com/hosting.php

Regards,
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
GH
Posts: 4
Joined: Tue Apr 04, 2006 10:01 am

Potential PHP version issue

Post by GH »

After speaking to my host about this they informed me that due to a recent server upgrade the PHP version had been updated to the latest and, as such, PHP generated emails required a From and To parameter. (Their words).

As im rather a novice at PHP, is their some way you could think of to manipulate the script to include these params or take account of a newer version of PHP? Im told the PHP version is 4.3.4 - is that the latest? Server is running windows.

Thanks in advance for assistance.
GH
Posts: 4
Joined: Tue Apr 04, 2006 10:01 am

Update: response from host - ini_set function

Post by GH »

You need to add the ini_set function into your email scripts. I have uploaded a test script, 8xbi22xy4-helpdesk/fh_emailtest.php that sends a basic email.
This is the response from my host (fasthosts). How would i incorporate this into the script and where pls?
<?php
//set the from address here
ini_set("sendmail_from", "gavin.hall@computer-direct.net");

// replace this with the email address that you want the test email to go to
$to = "external.test@gmail.com";

$subject = "test using the mail function";
$msg = "test email";

$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/html; charset=iso-8859-1\r\n";

mail ($to, $subject, $msg, $mailheaders);

?>
Thanks
GH
[/quote]
GH
Posts: 4
Joined: Tue Apr 04, 2006 10:01 am

Problem solved: heres how...

Post by GH »

//set the from address here
ini_set("sendmail_from", "SOMETHING@SOMETHING.COM");

// replace this with the email address that you want the test email to go to
$to = "SOMETHING@SOMETHING.COM";

$subject = "HELPDESK TICKET GENERATED";
$msg = $message;

$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/html; charset=iso-8859-1\r\n";

mail ($to, $subject, $msg, $mailheaders);

} // End if

Moderator - You may see fit to remove this if you wish as its a bit of an ugly fix given that i have very little idea what im doing. It basically revolves around the principle of generating the ini_set function before the email is sent. Anyway, maybe useful to some - i commented out the mail function in submit_ticket.php and jammed this in and now it works.
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Well Hesk code does have "From:" and "To:" in every mail so that shouldn't be a problem. Will leave your solution in case it helps anyone else.

Regards
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
pecky
Posts: 3
Joined: Sat Jan 16, 2010 8:59 am

Post by pecky »

Firstly apologies for bumping such an old thread, but it is the one i found whilst trying to resolve the same issue.

As mentioned Fasthosts policy is
1) Email must be sent to, or from, an email address hosted by Fasthosts. An email address hosted by Fasthosts is not the same as a domain name hosted by Fasthosts. If your domain's MX record points to another email provider, it will not count as being hosted by Fasthosts.

Use the PHP mail function and set the mail from using the following line of code - replacing $email_from with the correct domain name.

* ini_set("sendmail_from", " $email_from ");

You need to add a fifth "-f" parameter to the sendmail function. This will set the name of the from address.

* mail($email_to, $email_subject, $email_message, $headers, '-f'.$email_from);
I messed around with quite a few lines of code trying to get it to work, being a beginner at PHP it was a bit hit and miss. These are the modifications I made to get it to work as it should with Fasthosts servers.

in submit_ticket.php, reply_ticket.php and admin_reply_ticket.php I replace the applicable email code to

Code: Select all

/* Send e-mail */
ini_set("sendmail_from", "MYEMAIL@MYDOMAIN.COM");
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
@mail($email,$hesklang['ticket_received'],$msg,$headers,"-fMYEMAIL@MYDOMAIN.COM");

Code: Select all

/* Send e-mail to staff */
	ini_set("sendmail_from", "MYEMAIL@MYDOMAIN.COM"); 
	$email=implode(',',$admins);
	$headers = "From: $hesk_settings[noreply_mail]\n";
    $headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
    $headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
    $headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
	@mail($email,$hesklang['new_ticket_submitted'],$msg,$headers,"-fMYEMAIL@MYDOMAIN.COM");
It might be obvious amendments to some, but I'm pleased it is all now working as it should.
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Thanks for sharing, hope it helps others.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply