From: Geir on 3 Nov 2009 02:38 Hi I need to use sendmail's -f switch in the wrapper at the end of this message. Where / how do I put it? -f <address> This option sets the address of the envelope sender of a locally-generated message (also known as the return path). The option can normally be used only by a trusted user, but untrusted_set_sender can be set to allow untrusted users to use it. regards geir Code: require_once('../class.phpmailer.php'); $mail = new PHPMailer(); // defaults to using php "mail()" $mail->IsSendmail(); // telling the class to use SendMail transport $body = file_get_contents('contents.html'); $body = eregi_replace("[\]",'',$body); $mail->AddReplyTo("name(a)yourdomain.com","First Last"); $mail->SetFrom('name(a)yourdomain.com', 'First Last'); $mail->AddReplyTo("name(a)yourdomain.com","First Last"); $address = "whoto(a)otherdomain.com"; $mail->AddAddress($address, "John Doe"); $mail->Subject = "PHPMailer Test Subject via Sendmail, basic"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->AddAttachment("images/phpmailer.gif"); // attachment $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; }
From: The Natural Philosopher on 3 Nov 2009 04:43 Geir wrote: > Hi > > I need to use sendmail's -f switch in the wrapper at the end of this > message. Where / how do I put it? > > -f <address> > This option sets the address of the envelope sender of a > locally-generated message (also known as the return path). > The option can normally be used only by a trusted user, but > untrusted_set_sender can be set to allow untrusted users to > use it. > > regards geir > > > Code: > > require_once('../class.phpmailer.php'); > $mail = new PHPMailer(); // defaults to using php "mail()" > $mail->IsSendmail(); // telling the class to use SendMail transport > $body = file_get_contents('contents.html'); > $body = eregi_replace("[\]",'',$body); > $mail->AddReplyTo("name(a)yourdomain.com","First Last"); > $mail->SetFrom('name(a)yourdomain.com', 'First Last'); > $mail->AddReplyTo("name(a)yourdomain.com","First Last"); > $address = "whoto(a)otherdomain.com"; > $mail->AddAddress($address, "John Doe"); > $mail->Subject = "PHPMailer Test Subject via Sendmail, basic"; > $mail->AltBody = "To view the message, please use an HTML compatible > email viewer!"; // optional, comment out and test > $mail->MsgHTML($body); > $mail->AddAttachment("images/phpmailer.gif"); // attachment > $mail->AddAttachment("images/phpmailer_mini.gif"); // attachment > if(!$mail->Send()) { > echo "Mailer Error: " . $mail->ErrorInfo; > } else { > echo "Message sent!"; > } Try using the simple mail() function, rather than the class object.
From: Maxwell Lol on 3 Nov 2009 07:35 The Natural Philosopher <tnp(a)invalid.invalid> writes: > Try using the simple mail() function, rather than the class object. That won't work. He's trying to create a special "From: " address in the mail message, so it's not from the web server account. mail() won't do that, AFAIK. To the OP, I looked inside the source of the file class.phpmailer.php using http://www.organicdesign.co.nz/Class.phpmailer.php And searched for the -f flag. I'm guessing, but I think you need to set the Sender parameter, i.e. $mail->Sender = "Billy Bob Thorton <bbthorton(a)gmail.com>"; It also says that safe_mode has to be zero. I'm not sure how this is done. Hmm. This Google reference says that the code may be buggy, and the source should be changed. http://tracker.moodle.org/browse/MDL-2686 And this URL says safe mode is deprecated http://www.php.net/manual/en/ini.sect.safe-mode.php And this URL says there is a security flaw in the process http://larholm.com/2007/06/11/phpmailer-0day-remote-execution/ I don't know what version you are using. Be careful. Make sure you use the latest version of the code. I suspect that if you misconfigure it, and the web site is accessable from the net, spammers may hijack your system to send junk email.
From: Maxwell Lol on 3 Nov 2009 07:42 Maxwell Lol <nospam(a)com.invalid> writes: > The Natural Philosopher <tnp(a)invalid.invalid> writes: > >> Try using the simple mail() function, rather than the class object. > > That won't work. Sorry - I was confused (thinking about mail(1) instead of php mail(). This URL says there is a way to do it: http://www.php.net/manual/en/function.mail.php See additional_headers And example #2
From: The Natural Philosopher on 3 Nov 2009 10:52 Maxwell Lol wrote: > The Natural Philosopher <tnp(a)invalid.invalid> writes: > >> Try using the simple mail() function, rather than the class object. > > That won't work. > Tell my frigging copmuter that then. Works fine here. > He's trying to create a special "From: " address in the mail message, > so it's not from the web server account. > > mail() won't do that, AFAIK. > Works for me. .. mail($email, $subject, $message, $headers, "-f ".$return_path ); does the job fine, as long as the web server UID is trusted.
|
Next
|
Last
Pages: 1 2 Prev: Linux jobs outpacing Windows jobs Next: ghostscript ps to pcl and codepage |