הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   שליחת אימייל בPHP דרך SMTP חיצוני (https://hosts.co.il/forums/showthread.php?t=25834)

בניה 07-07-06 12:12

שליחת אימייל בPHP דרך SMTP חיצוני
 
ב"ה


יש אפשרות כזה?
בדקתי באתר PHP.net ולפי מה שהבנתי זה אולי אפשרי רק בוינדוס?

RS324 07-07-06 15:19

אתה יכול לעשות שליחה משרת אחר על ידי פתיחת SOCKET
והזנת נתונים לתוך.

אני חושב שיש אפשרות לשנות נתונים אולי עם INI_SET אבל צריך לבדוק את זה.

בניה 07-07-06 15:33

ציטוט:

נכתב במקור על ידי RS324
אתה יכול לעשות שליחה משרת אחר על ידי פתיחת SOCKET
והזנת נתונים לתוך.

אני חושב שיש אפשרות לשנות נתונים אולי עם INI_SET אבל צריך לבדוק את זה.

ב"ה


אוקי תודה.

RS324 07-07-06 16:30

בבקשה, מתוך PHP.NET , אני אישית לא בדקתי את הפונקציה אבל היא אמורה לעשות את העבודה.

כמובן שהיא צריכה לעבור כמה שינויים
PHP קוד:

function mymail($to,$subject,$message,$headers)
{

  
// set as global variable
  
global $GLOBAL;
 
  
// get From address
  
if ( preg_match("/From:.*?[A-Za-z0-9\._%-]+\@[A-Za-z0-9\._%-]+.*/"$headers$froms) ) {
     
preg_match("/[A-Za-z0-9\._%-]+\@[A-Za-z0-9\._%-]+/"$froms[0], $fromarr);
     
$from $fromarr[0];
  }

  
// Open an SMTP connection
  
$cp fsockopen ($GLOBAL["SMTP_SERVER"], $GLOBAL["SMTP_PORT"], &$errno, &$errstr1);
  if (!
$cp)
   return 
"Failed to even make a connection";
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "220") return "Failed to connect";

  
// Say hello...
  
fputs($cp"HELO ".$GLOBAL["SMTP_SERVER"]."\r\n");
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "250") return "Failed to Introduce";
 
  
// perform authentication
  
fputs($cp"auth login\r\n");
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "334") return "Failed to Initiate Authentication";
 
  
fputs($cpbase64_encode($GLOBAL["SMTP_USERNAME"])."\r\n");
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "334") return "Failed to Provide Username for Authentication";
 
  
fputs($cpbase64_encode($GLOBAL["SMTP_PASSWORD"])."\r\n");
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "235") return "Failed to Authenticate";

  
// Mail from...
  
fputs($cp"MAIL FROM: <$from>\r\n");
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "250") return "MAIL FROM failed";

  
// Rcpt to...
  
fputs($cp"RCPT TO: <$to>\r\n");
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "250") return "RCPT TO failed";

  
// Data...
  
fputs($cp"DATA\r\n");
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "354") return "DATA failed";

  
// Send To:, From:, Subject:, other headers, blank line, message, and finish
  // with a period on its own line (for end of message)
  
fputs($cp"To: $to\r\nFrom: $from\r\nSubject: $subject\r\n$headers\r\n\r\n$message\r\n.\r\n");
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "250") return "Message Body Failed";

  
// ...And time to quit...
  
fputs($cp,"QUIT\r\n");
  
$res=fgets($cp,256);
  if(
substr($res,0,3) != "221") return "QUIT failed";

  return 
true;



בניה 07-07-06 17:23

ב"ה



אני אנסה את זה , תודה רבה!

forils 08-07-06 14:06

גם אני ניסיתי וזה מציג שגיאה

RS324 08-07-06 15:39

איזה שגיאה ? ואמרתי שיכול להיות שצריך לערוך את הקוד קצת בשביל שהוא יעבוד...


כל הזמנים הם GMT +2. הזמן כעת הוא 17:27.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ