Page 1 of 2
Smtp email - from and bounce
Posted: Sat Nov 07, 2009 11:40 am
by webstyler
Hi
we send email with own smtp class
on this class use this
//Email From
fputs($smtpConnect, "MAIL FROM: $from" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailfromresponse'] = "$smtpResponse";
to set FROM
We must setting a different email from email bounce, so the Return-Path bust be this new email
How to this ?
Thanks
Re: Smtp email - from and bounce
Posted: Sat Nov 07, 2009 2:48 pm
by Eric!
Send a test email to yourself and look at the headers to find your problem. Some maiil servers are configured to deliver bounced messages to a specific address. Sometimes you can override it with -f like in this example:
Code: Select all
$from='me@email.com';
$returnpath="-f ".$from; // Forces the return path to be configured properly
$mail_sent = mail($to, $subject, $content, $headers, $returnpath);
Make sure you have the errors and warnings on to see if it fails to reconfigure.
Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 1:50 am
by webstyler
Hello
we send directly to smtp .. not use mail() function
so need to set return-path as FROM
fputs($smtpConnect, "MAIL FROM: $from" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailfromresponse'] = "$smtpResponse";
BUT not work if we send return-path with this method

Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 3:35 am
by bhavani
webstyler wrote:Hi
we send email with own smtp class
on this class use this
//Email From
fputs($smtpConnect, "MAIL FROM: $from" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailfromresponse'] = "$smtpResponse";
to set FROM
We must setting a different email from email bounce, so the Return-Path bust be this new email
How to this ?
Thanks
thanks
Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 4:17 am
by webstyler
bhavani wrote:webstyler wrote:Hi
we send email with own smtp class
on this class use this
//Email From
fputs($smtpConnect, "MAIL FROM: $from" . $newLine);
$smtpResponse = fgets($smtpConnect, 515);
$logArray['mailfromresponse'] = "$smtpResponse";
to set FROM
We must setting a different email from email bounce, so the Return-Path bust be this new email
How to this ?
Thanks
thanks
??
Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 9:56 am
by Eric!
webstyler wrote:we send directly to smtp .. not use mail() function
What are you doing? You still need an smtp server. Who configured the server? Get them to fix it.
Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 10:09 am
by webstyler
Eric! wrote:webstyler wrote:we send directly to smtp .. not use mail() function
What are you doing? You still need an smtp server. Who configured the server? Get them to fix it.
we send email not with mail() function but with connection to smtp because need to manage a lot of smtp server, not only local
so we have a class that use fsockopen and other comand to talk with smtp
all work fine
We need only to specify a return-path different from "FROM" value, and don't know how make this
Thanks
Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 10:57 am
by Apollo
Return-path is simply specified by the email's header, not a specific SMTP setting or something that requires a separate SMTP command.
Just make sure to include a line like
in the header of your email content (the stuff you send after the DATA command), and you're good.
By the way, you sure you want to implement this yourself? There are tons of open source solutions for this which really work fine. Personally I can recommend
PHPMailer (have good experience with it myself).
Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 11:43 am
by webstyler
Hello
We have try to add Return-path on the header send after DATA but this is replace with value "$from"
we send this header after DATA
From: $namefrom <$from>\nReply-To:
reply@domain.comt\nReturn-path: <$bounce>\nSubject: $subject\nTo: $to\n$headers\n\n$message\n.\n"
but when email arrived return-path is = $from
:/
We work on this own library for our customer that need function and procedure, we cannot use external class or framework

Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 12:54 pm
by Apollo
Strange, perhaps the SMTP server you're using does not allow custom Return-path addresses?
Have you tried connecting to a different SMTP server (from ISP, hosting provider, etc)? If that works, contact whoever is maintaining your current SMTP server, and tell them to fix this

Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 2:39 pm
by webstyler
uhm.. -f with mail() function return correct value
so think must go also with smtp send way .. :/
must know how to send "-
fbounce@domain.com" on smtp connection
Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 4:45 pm
by Eric!
You already did it by formatting the header sent to your server. Assuming your code is correctly defining $bounce and your header is properly formatted and your statement about sending the header AFTER the 'data' is just a language error or your talking about smpt commands(header is first followed by message body), then I would say your smtp server is causing the problem and your mail() function is using a config file that sets the server up correctly.
Traditionally you need CRLF at the end of each line.
http://www.faqs.org/rfcs/rfc822.html
Depends on what mailserver you are using....
Re: Smtp email - from and bounce
Posted: Mon Nov 09, 2009 5:05 pm
by webstyler
we test with mail() function and setting Return-path as header and not work, as most other server
work only if force with -f on extra header on mail()
so, think is the same on smtp command.. not work setting as header .. must be force or setting with specify rules
as tell before setting as header is ignored and email header have as return-path the same value sent on FROM smtp
Re: Smtp email - from and bounce
Posted: Tue Nov 10, 2009 10:42 am
by Apollo
As Eric suggests, try using CRLF (that's "\r\n") line endings instead of just \r in your $header string.
If that doesn't make a difference, can you send a test mail with mail() and the -f parameter, so you get the correct Return-path in the header, and then copy all relevant fields *exactly* from that header (including correct upper/lower-casing while you're at it). Does that bring any improvement?
Re: Smtp email - from and bounce
Posted: Tue Nov 10, 2009 11:00 am
by webstyler
Apollo wrote:As Eric suggests, try using CRLF (that's "\r\n") line endings instead of just \r in your $header string.
test with \r\n
nothing change, my return-path is ignored
Apollo wrote:
If that doesn't make a difference, can you send a test mail with mail() and the -f parameter, so you get the correct Return-path in the header, and then copy all relevant fields *exactly* from that header (including correct upper/lower-casing while you're at it). Does that bring any improvement?
That's already done.. but mail() is local and not from one server to other server.
Think the issue is on exim or cpanel, that remove my return-path and insert default value
