Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

pls help me with sending SMTP email


quochungluu

Recommended Posts

Posted

hi !

i am using this http://www.oscommerce.com/community/contributions,901

 

i have problem with Sending email SMTP , the email is always sent from my SMTP Authentication Username

I am using google mail server .

 

here is some my code in includes/classes/email.php

 

$to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr);

$from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr);

 

if (is_string($headers)) {

$headers = explode($this->lf, trim($headers));

}

 

for ($i=0; $i<count($headers); $i++) {

if (is_array($headers[$i])) {

for ($j=0; $j<count($headers[$i]); $j++) {

if ($headers[$i][$j] != '') {

$xtra_headers[] = $headers[$i][$j];

}

}

}

 

if ($headers[$i] != '') {

$xtra_headers[] = $headers[$i];

}

}

 

if (!isset($xtra_headers)) {

$xtra_headers = array();

}

 

// Hack in SMTP based email transport

if (EMAIL_TRANSPORT == 'smtp') {

 

include_once(DIR_WS_CLASSES . 'class.smtp.php');

 

// Build up the SMTP connection parameter list

$params['host'] = EMAIL_SMTP_HOST_SERVER; // The smtp server host/ip

$params['port'] = EMAIL_SMTP_PORT_SERVER; // The smtp server port

$params['helo'] = EMAIL_SMTP_HELO_SERVER; // helo/ehlo command string; typically your domain/hostname

$params['auth'] = EMAIL_SMTP_ACTIVE_PASSWORD; // Whether to use basic authentication or not

$params['user'] = EMAIL_SMTP_USERNAME; // Username for authentication

$params['pass'] = EMAIL_SMTP_PASSWORD; // Password for authentication

 

// Prepare the recipient names; there can be multiple recipients in the to_addr seperated by a comma.

// Create an array of the recipients and then strip off everything and just leave the internet style

// email address behind. For example: "MyCuteName <[email protected]>" => "[email protected]"

$recipients = explode(',', $to_addr);

for ($i = 0; $i < count($recipients); $i++) {

$recipients[$i] = trim(preg_replace( '/(.*)<(.*)>(.*)/', '$2', $recipients[$i]));

}

$send_params['recipients'] = $recipients;

 

// Timestamp the message

$date = date('r');

 

$send_params['headers'] = array_merge($this->headers, array("From: $from", "To: $to", "Subject: $subject", "Date: $date"));

 

// This is used as in the MAIL FROM: cmd

// It should end up as the Return-Path: header

$send_params['from'] = $from_addr;

 

// The body of the email message

$send_params['body'] = $this->output;

echo "<pre>";

print_r($send_params);

//Send the email via SMTP

 

return (is_object($smtp = smtp::connect($params)) AND $smtp->send($send_params));

 

when i debug the paramter it says "Array

(

[recipients] => Array

(

[0] => [email protected]

)

 

[headers] => Array

(

[0] => MIME-Version: 1.0

[1] => X-Mailer: osCommerce Mailer

[2] => Content-Type: text/plain; charset="iso-8859-1"

[3] => Content-Transfer-Encoding: 7bit

[4] => From: test <[email protected]>

[5] => To: "GUI TOI"

[6] => Subject: HUNG TEST

[7] => Date: Sun, 30 May 2010 00:53:22 +0900

)

 

[from] => [email protected]

[body] => testing google server mail

 

)

 

Can you pls help me to fix this ?

Posted

hi !

i am using this http://www.oscommerce.com/community/contributions,901

 

i have problem with Sending email SMTP , the email is always sent from my SMTP Authentication Username

I am using google mail server .

 

here is some my code in includes/classes/email.php

 

$to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr);

$from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr);

 

if (is_string($headers)) {

$headers = explode($this->lf, trim($headers));

}

 

for ($i=0; $i<count($headers); $i++) {

if (is_array($headers[$i])) {

for ($j=0; $j<count($headers[$i]); $j++) {

if ($headers[$i][$j] != '') {

$xtra_headers[] = $headers[$i][$j];

}

}

}

 

if ($headers[$i] != '') {

$xtra_headers[] = $headers[$i];

}

}

 

if (!isset($xtra_headers)) {

$xtra_headers = array();

}

 

// Hack in SMTP based email transport

if (EMAIL_TRANSPORT == 'smtp') {

 

include_once(DIR_WS_CLASSES . 'class.smtp.php');

 

// Build up the SMTP connection parameter list

$params['host'] = EMAIL_SMTP_HOST_SERVER; // The smtp server host/ip

$params['port'] = EMAIL_SMTP_PORT_SERVER; // The smtp server port

$params['helo'] = EMAIL_SMTP_HELO_SERVER; // helo/ehlo command string; typically your domain/hostname

$params['auth'] = EMAIL_SMTP_ACTIVE_PASSWORD; // Whether to use basic authentication or not

$params['user'] = EMAIL_SMTP_USERNAME; // Username for authentication

$params['pass'] = EMAIL_SMTP_PASSWORD; // Password for authentication

 

// Prepare the recipient names; there can be multiple recipients in the to_addr seperated by a comma.

// Create an array of the recipients and then strip off everything and just leave the internet style

// email address behind. For example: "MyCuteName <[email protected]>" => "[email protected]"

$recipients = explode(',', $to_addr);

for ($i = 0; $i < count($recipients); $i++) {

$recipients[$i] = trim(preg_replace( '/(.*)<(.*)>(.*)/', '$2', $recipients[$i]));

}

$send_params['recipients'] = $recipients;

 

// Timestamp the message

$date = date('r');

 

$send_params['headers'] = array_merge($this->headers, array("From: $from", "To: $to", "Subject: $subject", "Date: $date"));

 

// This is used as in the MAIL FROM: cmd

// It should end up as the Return-Path: header

$send_params['from'] = $from_addr;

 

// The body of the email message

$send_params['body'] = $this->output;

echo "<pre>";

print_r($send_params);

//Send the email via SMTP

 

return (is_object($smtp = smtp::connect($params)) AND $smtp->send($send_params));

 

when i debug the paramter it says "Array

(

[recipients] => Array

(

[0] => [email protected]

)

 

[headers] => Array

(

[0] => MIME-Version: 1.0

[1] => X-Mailer: osCommerce Mailer

[2] => Content-Type: text/plain; charset="iso-8859-1"

[3] => Content-Transfer-Encoding: 7bit

[4] => From: test <[email protected]>

[5] => To: "GUI TOI"

[6] => Subject: HUNG TEST

[7] => Date: Sun, 30 May 2010 00:53:22 +0900

)

 

[from] => [email protected]

[body] => testing google server mail

 

)

 

Can you pls help me to fix this ?

 

have you ever got the same problem before ?

Posted

hi !

i am using this http://www.oscommerce.com/community/contributions,901

 

i have problem with Sending email SMTP , the email is always sent from my SMTP Authentication Username

I am using google mail server .

<snip>

 

[from] => [email protected]

[body] => testing google server mail

 

)

 

Can you pls help me to fix this ?

Can you send email through your Google account using a FROM Yahoo email address? I don't use Google mail so I don't know, but I do run mail servers and if you send email through one of my server it had better be from the email account that you RECEIVE mail from...

 

Just something to consider

Community Bootstrap Edition, Edge

 

Avoid the most asked question. See How to Secure My Site and How do I...?

Posted

Can you send email through your Google account using a FROM Yahoo email address? I don't use Google mail so I don't know, but I do run mail servers and if you send email through one of my server it had better be from the email account that you RECEIVE mail from...

 

Just something to consider

yes, i am using google mail server .i don't want the email always sent from my Gmail account , i want to set by another email example for case :

 

tell your friend about this product .. the email should sent from your email to your friend's email ?Something like this

Posted

yes, i am using google mail server .i don't want the email always sent from my Gmail account , i want to set by another email example for case :

 

tell your friend about this product .. the email should sent from your email to your friend's email ?Something like this

can anyone pls help me

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...